bpmn-io / diagram-js

A toolbox for displaying and modifying diagrams on the web.
MIT License
1.69k stars 419 forks source link

svg dataset undefined #911

Closed Tarrowren closed 4 months ago

Tarrowren commented 4 months ago

Describe the Bug

/lib/util/RenderUtil.js


/**
* @param {Point[]} points
* @param {number|Object} [attrs]
* @param {number} [radius]
*
* @return {SVGElement}
*/
export function createLine(points, attrs, radius) {
if (isNumber(attrs)) {
radius = attrs;
attrs = null;
}

if (!attrs) { attrs = {}; }

const line = svgCreate("path", attrs);

if (isNumber(radius)) { line.dataset.cornerRadius = String(radius); }

return updateLine(line, points); }

/**

Steps to Reproduce

Steps to reproduce the behavior:

  1. do this
  2. do that

If possible, try to build a test case that reproduces your problem.

Expected Behavior

use svgAttr

Environment

nikku commented 4 months ago

Please provide us with clear steps to reproduce or we cannot help you. As it stands this report is not actionable for us.

Tarrowren commented 4 months ago

https://github.com/weolar/miniblink49/releases/download/2019.10.15/miniblink-191015.rar

I'm developing on an older platform, version Chrome 60, which doesn't support dataset fields. Currently I'm using this shim to temporarily solve this problem:

let line: SVGLineElement | null = document.createElementNS(
  "http://www.w3.org/2000/svg",
  "line",
);
if (!line.dataset) {
  (SVGElement.prototype as any).dataset = {};
}
line = null;
nikku commented 4 months ago

Chrome 60 is from 2017, according to caniuse it supports dataset on SVG elements. Even if it did not I wonder why you're forced to stay at a 10 year old browser.

As the given change was made in v11.9.0 I'd suggest you to use a bpmn-js version prior.