-
Notifications
You must be signed in to change notification settings - Fork 857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dia.CellView)!: separate alias and calc expression evaluation fro… #2335
feat(dia.CellView)!: separate alias and calc expression evaluation fro… #2335
Conversation
878830d
to
799faf7
Compare
…m attributes definition
799faf7
to
d23c09e
Compare
Is this related to #1421 ? 🤔 |
Currently, it allows you to switch off the support for camel-case. But if we move the alias logic to |
The conversion of attribute names to kebab-case should be done efficiently. AFAIK there is no native API that uses camel-cased names as it is in the case of CSS properties e.g. `el.style.borderWidth = '5px'. We can perhaps implement some caching like this: const aliasMap = {
xlinkHref: 'xlink:href',
xlinkShow: 'xlink:show',
xlinkRole: 'xlink:role',
xlinkType: 'xlink:type',
xlinkArcrole: 'xlink:arcrole',
xlinkTitle: 'xlink:title',
xlinkActuate: 'xlink:actuate',
xmlSpace: 'xml:space',
xmlLang: 'xml:lang',
xmlBase: 'xml:base',
preserveAspectRatio: 'preserveAspectRatio',
requiredExtensions: 'requiredExtensions',
requiredFeatures: 'requiredFeatures',
systemLanguage: 'systemLanguage',
externalResourcesRequired: 'externalResourcesRequired',
};
const aliases = new Proxy(aliasMap, {
get(map, property) {
if (property in map) {
return map[property];
} else {
const alias = map[property] = util.toKebabCase(property);
return alias;
}
}
}); Later, when using Vectorizer: // get an alias
console.log(V.aliases.strokeWidh);
// setting attributes
V(el).attr('strokeWidth', 5);
V(el).attr({ strokeDashoffset': 100 });
// define custom / missing alias
V.aliases.myAlias = 'my:alias'; |
At this point, I'm not sure if it's worth optimizing. See https://jsperf.app/disifi. |
🤔 it’s 11% slower on iPhone 12 mini, but indeed I don’t think it will really matter that much on desktop. Maybe on batch operations where multiple attrs of multiple cells will be modified? |
Using caching was slower in all browsers on Desktop for me. Yep, more testing is required. |
Obsolete now. See #2459. |
TBD