1
0
Fork 0

🚧 Progress on workbench

This commit is contained in:
Joost De Cock 2019-05-05 17:06:22 +02:00
parent 1a8fe110f8
commit 158c19ae1d
101 changed files with 1222 additions and 200 deletions

View file

@ -72,6 +72,22 @@ Attributes.prototype.renderIfPrefixIs = function(prefix = "") {
return svg;
};
/** Returns a props object for attributes with a fiven prefix
* typically used for data-text*/
Attributes.prototype.asPropsIfPrefixIs = function(prefix = "") {
let props = {};
let prefixLen = prefix.length;
for (let key in this.list) {
if (key.substr(0, prefixLen) === prefix) {
let propKey = key.substr(prefixLen);
if (propKey === "class") propKey = "className";
props[propKey] = this.get(key);
}
}
return props;
};
/** Returns a deep copy of this */
Attributes.prototype.clone = function() {
let clone = new Attributes();