Perform the following actions at the start of the cell view update:
evaluate the calc expressions used in the presentation attributes
translate (e.g. to dash-case) the presentation attribute names
This way, their evaluated value, and their true name become available for anyone dealing with them later (it's no longer needed to evaluate the calc() value multiple times or check for the existence of an attribute under different names).
Here's the new schema of how an attribute is set on the DOM node:
The PR also organizes the attributes into files based on their purpose.
Migration guide
It's only a breaking change if you define custom attributes (undocumented yet).
Before:
const MyElement = dia.Element.define('MyElement', {
root: {
myAttribute: 5
}
}, {
/* prototype */
}, {
/* static */
attributes: {
// the name must match the attribute as used on the model `root/myAttribute`.
myAttribute: {
set: function(value, bbox, node, attrs) {
return value + (attrs['myOtherAttribute'] || attrs['my-other-attribute']);
}
}
}
});
Now:
const MyElement = dia.Element.define('MyElement', {
root: {
myAttribute: 5 // could be dash-cased or camel-cased
}
}, {
/* prototype */
}, {
/* static */
attributes: {
// must be dash-cased (more precisely, it must be the true name returned by `V.attributeNames`)
'my-attribute': {
set: function(value, bbox, node, attrs) {
return value + attrs['my-other-attribute']; // always `true` name
}
}
}
});
Description
Perform the following actions at the start of the cell view update:
calc
expressions used in the presentation attributesThis way, their evaluated value, and their true name become available for anyone dealing with them later (it's no longer needed to evaluate the
calc()
value multiple times or check for the existence of an attribute under different names).Here's the new schema of how an attribute is set on the DOM node:
The PR also organizes the attributes into files based on their purpose.
Migration guide
It's only a breaking change if you define custom attributes (undocumented yet).
Before:
Now: