@torpor/view 0.0.11 → 0.0.12
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/CHANGELOG.md +6 -0
- package/dist/{ServerSlotRender-AWF3bD5B.d.cts → ServerSlotRender-t1sOutne.d.cts} +1 -1
- package/dist/{ServerSlotRender-AWF3bD5B.d.ts → ServerSlotRender-t1sOutne.d.ts} +1 -1
- package/dist/{chunk-GO2L324Q.js → chunk-T6JGCJ5T.js} +5 -2
- package/dist/chunk-T6JGCJ5T.js.map +1 -0
- package/dist/compile.cjs +38 -31
- package/dist/compile.cjs.map +1 -1
- package/dist/compile.d.cts +1 -0
- package/dist/compile.d.ts +1 -0
- package/dist/compile.js +38 -31
- package/dist/compile.js.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/ssr.cjs +4 -1
- package/dist/ssr.cjs.map +1 -1
- package/dist/ssr.d.cts +2 -2
- package/dist/ssr.d.ts +2 -2
- package/dist/ssr.js +1 -1
- package/dist/ssr.js.map +1 -1
- package/package.json +6 -6
- package/scripts/buildTestOutput.ts +2 -121
- package/src/compile/build/client/buildAddFragment.ts +1 -1
- package/src/compile/build/client/buildAwaitNode.ts +1 -1
- package/src/compile/build/client/buildComponentNode.ts +1 -1
- package/src/compile/build/client/buildControlNode.ts +1 -1
- package/src/compile/build/client/buildElementNode.ts +7 -1
- package/src/compile/build/client/buildForNode.ts +1 -1
- package/src/compile/build/client/buildFragment.ts +1 -1
- package/src/compile/build/client/buildFragmentText.ts +7 -1
- package/src/compile/build/client/buildHeadNode.ts +1 -1
- package/src/compile/build/client/buildHtmlNode.ts +1 -1
- package/src/compile/build/client/buildIfNode.ts +1 -1
- package/src/compile/build/client/buildMount.ts +1 -1
- package/src/compile/build/client/buildNode.ts +1 -1
- package/src/compile/build/client/buildReplaceNode.ts +1 -1
- package/src/compile/build/client/buildRootNode.ts +1 -1
- package/src/compile/build/client/buildRun.ts +1 -1
- package/src/compile/build/client/buildScriptNode.ts +1 -1
- package/src/compile/build/client/buildSlotNode.ts +1 -1
- package/src/compile/build/client/buildSwitchNode.ts +1 -1
- package/src/compile/build/client/buildTextNode.ts +1 -1
- package/src/compile/build/client/replaceForVarNames.ts +1 -1
- package/src/compile/build/server/buildServerAwaitNode.ts +1 -1
- package/src/compile/build/server/buildServerComponentNode.ts +1 -1
- package/src/compile/build/server/buildServerControlNode.ts +1 -1
- package/src/compile/build/server/buildServerElementNode.ts +9 -1
- package/src/compile/build/server/buildServerForNode.ts +1 -1
- package/src/compile/build/server/buildServerHtmlNode.ts +1 -1
- package/src/compile/build/server/buildServerIfNode.ts +1 -1
- package/src/compile/build/server/buildServerNode.ts +5 -1
- package/src/compile/build/server/buildServerReplaceNode.ts +1 -1
- package/src/compile/build/server/buildServerRootNode.ts +5 -1
- package/src/compile/build/server/buildServerScriptNode.ts +1 -1
- package/src/compile/build/server/buildServerSlotNode.ts +1 -1
- package/src/compile/build/server/buildServerSpecialNode.ts +1 -1
- package/src/compile/build/server/buildServerSwitchNode.ts +1 -1
- package/src/compile/build/server/buildServerTextNode.ts +1 -1
- package/src/compile/build/utils/isFullyReactive.ts +1 -1
- package/src/compile/build/utils/isReactive.ts +1 -1
- package/src/compile/build/utils/isReactiveAttribute.ts +1 -1
- package/src/compile/parse/addSpaceElement.ts +4 -1
- package/src/compile/parse/parseControl.ts +4 -1
- package/src/compile/parse/parseImports.ts +1 -1
- package/src/compile/parse/parseMarkup.ts +1 -1
- package/src/compile/parse/parseStyles.ts +1 -1
- package/src/compile/parse/scopeStyles.ts +13 -21
- package/src/compile/parse/slottifyChildNodes.ts +1 -1
- package/src/compile/parse/utils/addError.ts +5 -1
- package/src/compile/parse/utils/consumeUntil.ts +1 -1
- package/src/compile/parse/utils/isAlphaNumeric.ts +1 -1
- package/src/compile/parse/utils/isAlphaNumericChar.ts +1 -1
- package/src/compile/parse/utils/isSpace.ts +1 -1
- package/src/compile/parse/utils/isSpaceChar.ts +1 -1
- package/src/compile/types/nodes/TemplateNode.ts +3 -0
- package/src/compile/utils/Builder.ts +3 -3
- package/src/compile/utils/trimEnd.ts +1 -1
- package/src/compile/utils/trimMatched.ts +1 -1
- package/src/compile/utils/trimQuotes.ts +1 -1
- package/src/compile/utils/trimStart.ts +1 -1
- package/src/compile/utils/trimStartAndEnd.ts +1 -1
- package/src/compile/utils/voidTags.ts +1 -1
- package/src/debug/printHtml.ts +1 -1
- package/src/motion/animate.ts +1 -1
- package/src/render/$mount.ts +1 -1
- package/src/render/$run.ts +1 -1
- package/src/render/$serverMount.ts +1 -1
- package/src/render/$serverRun.ts +1 -1
- package/src/render/$stream.ts +1 -1
- package/src/render/addAnimation.ts +1 -1
- package/src/render/addEvent.ts +1 -1
- package/src/render/addFragment.ts +1 -1
- package/src/render/applyProps.ts +1 -1
- package/src/render/clearRange.ts +1 -1
- package/src/render/createComment.ts +1 -1
- package/src/render/createElement.ts +1 -1
- package/src/render/createFragment.ts +1 -1
- package/src/render/createText.ts +1 -1
- package/src/render/flushMountEffects.ts +1 -1
- package/src/render/getClasses.ts +4 -1
- package/src/render/hydrate.ts +1 -1
- package/src/render/hydrateRoot.ts +1 -1
- package/src/render/mount.ts +1 -1
- package/src/render/moveRange.ts +1 -1
- package/src/render/popRange.ts +1 -1
- package/src/render/runControl.ts +1 -1
- package/src/render/runControlBranch.ts +1 -1
- package/src/render/runList.ts +1 -1
- package/src/render/runListItems.ts +1 -1
- package/src/render/setAttribute.ts +1 -1
- package/src/render/setDynamicElement.ts +1 -1
- package/src/watch/proxyGet.ts +1 -1
- package/src/watch/removeEffect.ts +1 -1
- package/src/watch/runEffect.ts +1 -1
- package/src/watch/symbols.ts +1 -1
- package/src/watch/trackEffect.ts +1 -1
- package/src/watch/transferEffects.ts +1 -1
- package/src/watch/triggerEffects.ts +1 -1
- package/test/bench/components/output/Bench-client.ts +0 -204
- package/test/bench/components/output/Bench-server.ts +0 -130
- package/test/bench/components/temp/Bench-client-5fee290225ae4771aa847360006123671e8f17f1.ts +208 -0
- package/test/bench/components/temp/Bench-server-00cefa588803c01ca4f2741c595e4f045cdd101e.ts +130 -0
- package/test/build-server/components/{output/IfNested-client.ts → temp/IfNested-client-979db97eea5b4595550b9b46f297f3fbc31796d2.ts} +11 -0
- package/test/buildHtml.ts +1 -1
- package/test/buildOutputFiles.ts +47 -12
- package/test/class/class.test.ts +29 -6
- package/test/class/components/Class.torp +15 -1
- package/test/class/components/output/Class-client.ts +10 -6
- package/test/class/components/output/Class-server.ts +1 -1
- package/test/class/components/temp/{Class-client-600bf865c14f1052d24e1c79242f837aaf5ae5e8.ts → Class-client-8c3f9e0257cc2b687e9bb7106cccbab94a4b5adf.ts} +10 -6
- package/test/class/components/temp/Class-server-2218c3284845fdab80d1a41ebace9a9e2ddd6fc1.ts +17 -0
- package/test/component/components/temp/Header-client-ac151eea86e3f6b058fab101661e13ae73864968.ts +34 -0
- package/test/component/components/temp/Header-server-4f10f2332f3ca7a097517cfb938ab1e6f31d68ac.ts +17 -0
- package/test/console/components/temp/{Console-client-254d7d4799471401334d698b1631ab1cb5b70558.ts → Console-client-2f206752ce59e59fba9bb91263b4102fd515951e.ts} +1 -1
- package/test/console/components/temp/Console-server-b4b15f7a0d1d2b50d87bad4870e1b8d368707c04.ts +17 -0
- package/test/globalSetup.ts +1 -1
- package/test/helpers.ts +6 -2
- package/test/hydrateComponent.ts +1 -1
- package/test/importComponent.ts +12 -40
- package/test/mountComponent.ts +5 -1
- package/test/party/components/temp/AnswerButton-client-243454cd7bf84c648f244b3587e60d01a0401039.ts +33 -0
- package/test/party/components/temp/AnswerButton-server-938e46c1d2510ea37454854ef527e4aa64eb8e52.ts +16 -0
- package/test/party/components/temp/FunnyButton-client-2e6bec8259065b5bc9ae16d1ca93dd1bd0c56b7c.ts +40 -0
- package/test/party/components/temp/FunnyButton-server-e8ab55e47c735f7e42c55d2b7504dfa4190a1b40.ts +32 -0
- package/test/party/components/temp/Time-client-7ba4ca9322af2cb88a873c812fc776760c337c64.ts +47 -0
- package/test/party/components/temp/Time-server-08f66c7f3f32b13de06d75fe679cf58b5727c473.ts +31 -0
- package/test/party/components/temp/UserProfile-client-938bcef20a2555de22aca939022a32742ac5e729.ts +51 -0
- package/test/party/components/temp/UserProfile-server-9df5c59b8797fa67c479bc76450104d45e6076f9.ts +22 -0
- package/test/party/components/temp/UserProfileContext-client-93211cdba795b8baf926f60f5b17da90701743b3.ts +44 -0
- package/test/party/components/temp/UserProfileContext-server-cf58767df1e2d1dde919f59de73cdd9764bbc006.ts +20 -0
- package/test/slots/components/temp/Article-client-741f94eab2e96655f4c9d69ccd7d9c7cc998f4ce.ts +41 -0
- package/test/slots/components/temp/Article-server-a6bd47a621cc213db4313eb775a52246541dd203.ts +28 -0
- package/test/slots/components/temp/Header-client-e2e1e7d60b48b0841cd0c20224f520330ca96458.ts +38 -0
- package/test/slots/components/temp/Header-server-1c195508a91c32822da22a08576c8a30c9070636.ts +22 -0
- package/test/slots/components/temp/List-client-0659d999cfb48b865fe5b8aaaf2a4ddac3a8a8b6.ts +76 -0
- package/test/slots/components/temp/List-server-4b76485a259d054187edad8aa691d80ac918ad86.ts +25 -0
- package/test/special-component/components/temp/BigTitle-client-881a9f84876fb3f6d994736edb253b96e71de926.ts +32 -0
- package/test/special-component/components/temp/BigTitle-server-9efc738f5eb131a4b859c4a99a8e255d93834e9a.ts +20 -0
- package/test/special-component/components/temp/SmallTitle-client-25b3097b7ae47848dd82967403faf7745fc43388.ts +32 -0
- package/test/special-component/components/temp/SmallTitle-server-fc105db9a91b83644d67e049ce583a3d1a61f50c.ts +20 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +7 -2
- package/vitest.config.ts +2 -2
- package/dist/chunk-GO2L324Q.js.map +0 -1
- package/test/bench/components/temp/Bench-client-3efcd3b6c03c7a51368df3b8b1bdf2e7fa722432.ts +0 -126
- package/test/build-server/components/IfNested.d.ts +0 -18
- package/test/class/components/temp/Class-server-082505b03612c762384ffff329472db3f55b8097.ts +0 -17
- /package/test/build-server/components/{output/IfNested-server.ts → temp/IfNested-server-3c4e4b6f2162c0906cef685830219b9ea9ee985c.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,7 @@ type Cleanup = () => void;
|
|
|
6
6
|
|
|
7
7
|
declare function formatText(value: any): string;
|
|
8
8
|
|
|
9
|
-
declare function getClasses(value: unknown): string;
|
|
9
|
+
declare function getClasses(value: unknown, styleHash?: string): string;
|
|
10
10
|
|
|
11
11
|
declare function getStyles(value: Record<string, any>): string;
|
|
12
12
|
|
|
@@ -6,7 +6,7 @@ type Cleanup = () => void;
|
|
|
6
6
|
|
|
7
7
|
declare function formatText(value: any): string;
|
|
8
8
|
|
|
9
|
-
declare function getClasses(value: unknown): string;
|
|
9
|
+
declare function getClasses(value: unknown, styleHash?: string): string;
|
|
10
10
|
|
|
11
11
|
declare function getStyles(value: Record<string, any>): string;
|
|
12
12
|
|
|
@@ -4,9 +4,12 @@ function formatText(value) {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
// src/render/getClasses.ts
|
|
7
|
-
function getClasses(value) {
|
|
7
|
+
function getClasses(value, styleHash) {
|
|
8
8
|
let classes = [];
|
|
9
9
|
gatherNames("", value, classes);
|
|
10
|
+
if (styleHash) {
|
|
11
|
+
classes.push(styleHash);
|
|
12
|
+
}
|
|
10
13
|
return classes.join(" ");
|
|
11
14
|
}
|
|
12
15
|
function gatherNames(name, value, classes) {
|
|
@@ -39,4 +42,4 @@ export {
|
|
|
39
42
|
getClasses,
|
|
40
43
|
getStyles
|
|
41
44
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-T6JGCJ5T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render/formatText.ts","../src/render/getClasses.ts","../src/render/getStyles.ts"],"sourcesContent":["export default function formatText(value: any): string {\n\treturn value ?? \"\";\n}\n","export default function getClasses(value: unknown, styleHash?: string): string {\n\tlet classes: string[] = [];\n\tgatherNames(\"\", value, classes);\n\tif (styleHash) {\n\t\tclasses.push(styleHash);\n\t}\n\treturn classes.join(\" \");\n}\n\nfunction gatherNames(name: unknown, value: unknown, classes: string[]) {\n\tif (value) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (let v of value) {\n\t\t\t\tgatherNames(v, v, classes);\n\t\t\t}\n\t\t} else if (typeof value === \"object\") {\n\t\t\tfor (let [n, v] of Object.entries(value)) {\n\t\t\t\tgatherNames(n, v, classes);\n\t\t\t}\n\t\t} else {\n\t\t\tclasses.push(name as string);\n\t\t}\n\t}\n}\n","export default function getStyles(value: Record<string, any>): string {\n\tlet styles: string[] = [];\n\tfor (let [n, v] of Object.entries(value)) {\n\t\tstyles.push(`${n}: ${v}`);\n\t}\n\treturn styles.join(\"; \");\n}\n"],"mappings":";AAAe,SAAR,WAA4B,OAAoB;AACtD,SAAO,SAAS;AACjB;;;ACFe,SAAR,WAA4B,OAAgB,WAA4B;AAC9E,MAAI,UAAoB,CAAC;AACzB,cAAY,IAAI,OAAO,OAAO;AAC9B,MAAI,WAAW;AACd,YAAQ,KAAK,SAAS;AAAA,EACvB;AACA,SAAO,QAAQ,KAAK,GAAG;AACxB;AAEA,SAAS,YAAY,MAAe,OAAgB,SAAmB;AACtE,MAAI,OAAO;AACV,QAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,eAAS,KAAK,OAAO;AACpB,oBAAY,GAAG,GAAG,OAAO;AAAA,MAC1B;AAAA,IACD,WAAW,OAAO,UAAU,UAAU;AACrC,eAAS,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAK,GAAG;AACzC,oBAAY,GAAG,GAAG,OAAO;AAAA,MAC1B;AAAA,IACD,OAAO;AACN,cAAQ,KAAK,IAAc;AAAA,IAC5B;AAAA,EACD;AACD;;;ACvBe,SAAR,UAA2B,OAAoC;AACrE,MAAI,SAAmB,CAAC;AACxB,WAAS,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAK,GAAG;AACzC,WAAO,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;AAAA,EACzB;AACA,SAAO,OAAO,KAAK,IAAI;AACxB;","names":[]}
|
package/dist/compile.cjs
CHANGED
|
@@ -91,6 +91,17 @@ var HYDRATION_START_COMMENT = "<![>";
|
|
|
91
91
|
var HYDRATION_END_COMMENT = "<!]>";
|
|
92
92
|
var HYDRATION_BRANCH_COMMENT = "<!^>";
|
|
93
93
|
|
|
94
|
+
// src/compile/utils/trimQuotes.ts
|
|
95
|
+
function trimQuotes(text) {
|
|
96
|
+
let start = 0;
|
|
97
|
+
let end = text.length;
|
|
98
|
+
while (text[start] === "'" && text[end - 1] === "'" || text[start] === '"' && text[end - 1] === '"' || text[start] === "`" && text[end - 1] === "`") {
|
|
99
|
+
start += 1;
|
|
100
|
+
end -= 1;
|
|
101
|
+
}
|
|
102
|
+
return text.substring(start, end);
|
|
103
|
+
}
|
|
104
|
+
|
|
94
105
|
// src/compile/build/utils/isReactive.ts
|
|
95
106
|
function isReactive(text) {
|
|
96
107
|
return text.includes("{") && text.includes("}");
|
|
@@ -198,6 +209,9 @@ function buildElementFragmentText(node, status, fragments, currentFragment) {
|
|
|
198
209
|
if (a.name.startsWith("data-")) {
|
|
199
210
|
return `${a.name}=""`;
|
|
200
211
|
}
|
|
212
|
+
} else if (a.name === "class" && node.scopeStyles) {
|
|
213
|
+
let value = a.value ? `"${trimQuotes(a.value)} torp-${status.styleHash}"` : `"torp-${status.styleHash}"`;
|
|
214
|
+
return `${a.name}=${value}`;
|
|
201
215
|
} else {
|
|
202
216
|
return `${a.name}${a.value != null ? `=${a.value}` : ""}`;
|
|
203
217
|
}
|
|
@@ -267,17 +281,6 @@ function trimMatched(text, startChar, endChar) {
|
|
|
267
281
|
return text.substring(start, end);
|
|
268
282
|
}
|
|
269
283
|
|
|
270
|
-
// src/compile/utils/trimQuotes.ts
|
|
271
|
-
function trimQuotes(text) {
|
|
272
|
-
let start = 0;
|
|
273
|
-
let end = text.length;
|
|
274
|
-
while (text[start] === "'" && text[end - 1] === "'" || text[start] === '"' && text[end - 1] === '"' || text[start] === "`" && text[end - 1] === "`") {
|
|
275
|
-
start += 1;
|
|
276
|
-
end -= 1;
|
|
277
|
-
}
|
|
278
|
-
return text.substring(start, end);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
284
|
// src/compile/build/utils/isFullyReactive.ts
|
|
282
285
|
function isFullyReactive(text) {
|
|
283
286
|
return text.trim().startsWith("{") && text.trim().endsWith("}");
|
|
@@ -1534,9 +1537,15 @@ function buildElementAttributes(node, varName, status, b) {
|
|
|
1534
1537
|
} else if (name.startsWith(":transition")) {
|
|
1535
1538
|
buildTransitionAttribute(node, varName, name, value, status, b);
|
|
1536
1539
|
} else if (name === "class") {
|
|
1540
|
+
if (node.scopeStyles) {
|
|
1541
|
+
value += `+ "torp-${status.styleHash}"`;
|
|
1542
|
+
}
|
|
1537
1543
|
buildRun("setClassName", `${varName}.className = ${value};`, status, b);
|
|
1538
1544
|
} else if (name === ":class") {
|
|
1539
1545
|
status.imports.add("t_class");
|
|
1546
|
+
if (node.scopeStyles) {
|
|
1547
|
+
value += `, "torp-${status.styleHash}"`;
|
|
1548
|
+
}
|
|
1540
1549
|
buildRun("setClasses", `${varName}.className = t_class(${value});`, status, b);
|
|
1541
1550
|
} else if (name === ":style") {
|
|
1542
1551
|
status.imports.add("t_style");
|
|
@@ -2449,6 +2458,9 @@ function buildElementAttributes2(node, status) {
|
|
|
2449
2458
|
attributes.push(`${propName}="\${${valueOrDefault}}"`);
|
|
2450
2459
|
} else if (name === ":class") {
|
|
2451
2460
|
status.imports.add("t_class");
|
|
2461
|
+
if (node.scopeStyles) {
|
|
2462
|
+
value += `, "torp-${status.styleHash}"`;
|
|
2463
|
+
}
|
|
2452
2464
|
attributes.push(`class="\${t_class(${value})}"`);
|
|
2453
2465
|
} else if (name === ":style") {
|
|
2454
2466
|
status.imports.add("t_style");
|
|
@@ -2462,6 +2474,9 @@ function buildElementAttributes2(node, status) {
|
|
|
2462
2474
|
attributes.push(
|
|
2463
2475
|
`${name}="${trimQuotes(value).replaceAll("{", "${t_attr(").replaceAll("}", ")}")}"`
|
|
2464
2476
|
);
|
|
2477
|
+
} else if (name === "class" && node.scopeStyles) {
|
|
2478
|
+
value = value ? `"${trimQuotes(value)} torp-${status.styleHash}"` : `"torp-${status.styleHash}"`;
|
|
2479
|
+
attributes.push(`${name}="${trimQuotes(value).replaceAll('"', """)}"`);
|
|
2465
2480
|
} else if (value != null) {
|
|
2466
2481
|
attributes.push(`${name}="${trimQuotes(value).replaceAll('"', """)}"`);
|
|
2467
2482
|
} else {
|
|
@@ -3589,40 +3604,32 @@ function scopeStyles(status) {
|
|
|
3589
3604
|
for (let block of component.style.blocks) {
|
|
3590
3605
|
collectStyleSelectors(block, selectors);
|
|
3591
3606
|
}
|
|
3592
|
-
scopeStylesOnNode(component.markup, selectors
|
|
3607
|
+
scopeStylesOnNode(component.markup, selectors);
|
|
3593
3608
|
}
|
|
3594
3609
|
}
|
|
3595
3610
|
}
|
|
3596
|
-
function scopeStylesOnNode(node, selectors
|
|
3611
|
+
function scopeStylesOnNode(node, selectors) {
|
|
3597
3612
|
if (isElementNode(node)) {
|
|
3598
|
-
let
|
|
3599
|
-
if (!
|
|
3613
|
+
let scopeStyles2 = selectors.includes(node.tagName);
|
|
3614
|
+
if (!scopeStyles2) {
|
|
3600
3615
|
for (let a of node.attributes) {
|
|
3601
3616
|
if (a.name === "class" || a.name === ":class") {
|
|
3602
|
-
|
|
3617
|
+
scopeStyles2 = true;
|
|
3603
3618
|
} else if (a.name === "id" && a.value) {
|
|
3604
|
-
|
|
3619
|
+
scopeStyles2 = selectors.includes(`#${trimQuotes(a.value)}`);
|
|
3605
3620
|
} else if (a.name === "class" && a.value) {
|
|
3606
|
-
|
|
3621
|
+
scopeStyles2 = selectors.includes(`.${trimQuotes(a.value)}`);
|
|
3622
|
+
}
|
|
3623
|
+
if (scopeStyles2) {
|
|
3624
|
+
break;
|
|
3607
3625
|
}
|
|
3608
|
-
if (addClass) break;
|
|
3609
|
-
}
|
|
3610
|
-
}
|
|
3611
|
-
if (addClass) {
|
|
3612
|
-
let classAttribute = node.attributes.find((a) => a.name === "class");
|
|
3613
|
-
if (classAttribute && classAttribute.value) {
|
|
3614
|
-
classAttribute.value = `"${trimQuotes(classAttribute.value)} torp-${styleHash}"`;
|
|
3615
|
-
} else {
|
|
3616
|
-
node.attributes.push({
|
|
3617
|
-
name: "class",
|
|
3618
|
-
value: `"torp-${styleHash}"`
|
|
3619
|
-
});
|
|
3620
3626
|
}
|
|
3621
3627
|
}
|
|
3628
|
+
node.scopeStyles = scopeStyles2;
|
|
3622
3629
|
}
|
|
3623
3630
|
if (isParentNode(node)) {
|
|
3624
3631
|
for (let child of node.children) {
|
|
3625
|
-
scopeStylesOnNode(child, selectors
|
|
3632
|
+
scopeStylesOnNode(child, selectors);
|
|
3626
3633
|
}
|
|
3627
3634
|
}
|
|
3628
3635
|
}
|