@lukekaalim/act-web 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/prop.js +24 -3
package/package.json
CHANGED
package/prop.js
CHANGED
|
@@ -55,6 +55,23 @@ export const setAttributeProp = (
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
export const setDOMTokenList = (
|
|
59
|
+
list/*: DOMTokenList*/,
|
|
60
|
+
prop/*: PropDiff*/
|
|
61
|
+
) => {
|
|
62
|
+
const next = prop.next;
|
|
63
|
+
if (typeof prop.next === 'string')
|
|
64
|
+
// $FlowFixMe
|
|
65
|
+
return list.value = prop.next;
|
|
66
|
+
else if (Array.isArray(next)) {
|
|
67
|
+
const removed = [...list].filter(e => !next.includes(e));
|
|
68
|
+
for (const item of removed)
|
|
69
|
+
list.remove(item);
|
|
70
|
+
for (const item of next)
|
|
71
|
+
typeof item === 'string' && list.add(item);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
58
75
|
export const setHTMLProp = (
|
|
59
76
|
element/*: HTMLElement | SVGElement*/,
|
|
60
77
|
prop/*: PropDiff*/
|
|
@@ -63,9 +80,13 @@ export const setHTMLProp = (
|
|
|
63
80
|
setEventListenerProp(element, prop);
|
|
64
81
|
else if (prop.key === 'style')
|
|
65
82
|
setStylesProp(element, prop);
|
|
66
|
-
else if (prop.key in element && !propBlacklist.has(prop.key) && element instanceof HTMLElement)
|
|
67
|
-
|
|
68
|
-
(
|
|
83
|
+
else if (prop.key in element && !propBlacklist.has(prop.key) && element instanceof HTMLElement) {
|
|
84
|
+
const htmlElement = (element/*: Object*/);
|
|
85
|
+
if (typeof htmlElement[prop.key] === DOMTokenList)
|
|
86
|
+
setDOMTokenList(htmlElement[prop.key], prop);
|
|
87
|
+
else
|
|
88
|
+
htmlElement[prop.key] = prop.next;
|
|
89
|
+
}
|
|
69
90
|
else
|
|
70
91
|
setAttributeProp(element, prop);
|
|
71
92
|
}
|