@unhead/dom 0.2.3 → 0.2.4
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/dist/index.cjs +9 -5
- package/dist/index.mjs +9 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -14,20 +14,21 @@ const createElement = (tag, document) => {
|
|
|
14
14
|
function setAttributesWithSideEffects(head, $el, entry, tag) {
|
|
15
15
|
const attrs = tag.props || {};
|
|
16
16
|
const sdeKey = `${tag._p}:attr`;
|
|
17
|
-
|
|
18
|
-
delete entry._sde[key] && fn();
|
|
19
|
-
});
|
|
17
|
+
const sdeToRun = { ...entry._sde };
|
|
20
18
|
Object.entries(attrs).forEach(([k, value]) => {
|
|
21
19
|
value = String(value);
|
|
22
20
|
const attrSdeKey = `${sdeKey}:${k}`;
|
|
23
21
|
head._removeQueuedSideEffect(attrSdeKey);
|
|
22
|
+
delete sdeToRun[attrSdeKey];
|
|
24
23
|
if (k === "class") {
|
|
25
24
|
for (const c of value.split(" ")) {
|
|
25
|
+
const classSdeKey = `${sdeKey}:class:${c}`;
|
|
26
26
|
if (!$el.classList.contains(c)) {
|
|
27
27
|
$el.classList.add(c);
|
|
28
|
-
|
|
29
|
-
entry._sde[`${attrSdeKey}:${c}`] = () => $el.classList.remove(c);
|
|
28
|
+
entry._sde[classSdeKey] = () => $el.classList.remove(c);
|
|
30
29
|
}
|
|
30
|
+
head._removeQueuedSideEffect(classSdeKey);
|
|
31
|
+
delete sdeToRun[classSdeKey];
|
|
31
32
|
}
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
@@ -37,6 +38,9 @@ function setAttributesWithSideEffects(head, $el, entry, tag) {
|
|
|
37
38
|
entry._sde[attrSdeKey] = () => $el.removeAttribute(k);
|
|
38
39
|
}
|
|
39
40
|
});
|
|
41
|
+
Object.entries(sdeToRun).filter(([key]) => key.startsWith(sdeKey)).forEach(([key, fn]) => {
|
|
42
|
+
delete entry._sde[key] && fn();
|
|
43
|
+
});
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
async function renderDOMHead(head, options = {}) {
|
package/dist/index.mjs
CHANGED
|
@@ -12,20 +12,21 @@ const createElement = (tag, document) => {
|
|
|
12
12
|
function setAttributesWithSideEffects(head, $el, entry, tag) {
|
|
13
13
|
const attrs = tag.props || {};
|
|
14
14
|
const sdeKey = `${tag._p}:attr`;
|
|
15
|
-
|
|
16
|
-
delete entry._sde[key] && fn();
|
|
17
|
-
});
|
|
15
|
+
const sdeToRun = { ...entry._sde };
|
|
18
16
|
Object.entries(attrs).forEach(([k, value]) => {
|
|
19
17
|
value = String(value);
|
|
20
18
|
const attrSdeKey = `${sdeKey}:${k}`;
|
|
21
19
|
head._removeQueuedSideEffect(attrSdeKey);
|
|
20
|
+
delete sdeToRun[attrSdeKey];
|
|
22
21
|
if (k === "class") {
|
|
23
22
|
for (const c of value.split(" ")) {
|
|
23
|
+
const classSdeKey = `${sdeKey}:class:${c}`;
|
|
24
24
|
if (!$el.classList.contains(c)) {
|
|
25
25
|
$el.classList.add(c);
|
|
26
|
-
|
|
27
|
-
entry._sde[`${attrSdeKey}:${c}`] = () => $el.classList.remove(c);
|
|
26
|
+
entry._sde[classSdeKey] = () => $el.classList.remove(c);
|
|
28
27
|
}
|
|
28
|
+
head._removeQueuedSideEffect(classSdeKey);
|
|
29
|
+
delete sdeToRun[classSdeKey];
|
|
29
30
|
}
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
@@ -35,6 +36,9 @@ function setAttributesWithSideEffects(head, $el, entry, tag) {
|
|
|
35
36
|
entry._sde[attrSdeKey] = () => $el.removeAttribute(k);
|
|
36
37
|
}
|
|
37
38
|
});
|
|
39
|
+
Object.entries(sdeToRun).filter(([key]) => key.startsWith(sdeKey)).forEach(([key, fn]) => {
|
|
40
|
+
delete entry._sde[key] && fn();
|
|
41
|
+
});
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
async function renderDOMHead(head, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/dom",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"packageManager": "pnpm@7.14.0",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@unhead/schema": "0.2.
|
|
33
|
+
"@unhead/schema": "0.2.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"zhead": "1.0.0-beta.10"
|