You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We keep a cache of parsed static fragments; these need to be reset
50
+
// since they can vary based on whether we use the legacy scope token or not.
51
+
window.__lwcResetFragmentCache();
52
+
// Reset template object for clean state between tests
53
+
Ctor.resetTemplate();
54
+
});
36
55
37
-
it('W-16614556 should not render arbitrary content via stylesheet token', async () => {
38
-
const elm = createElement('x-component', { is: Component });
39
-
elm.propToUse = prop;
40
-
try {
41
-
document.body.appendChild(elm);
42
-
} catch (err) {
43
-
// In synthetic custom element lifecycle, the error is thrown synchronously on `appendChild`
44
-
caughtError = err;
45
-
}
56
+
it('W-16614556 should not render arbitrary content via stylesheet token', async () => {
57
+
const elm = createElement(tagName, { is: Ctor });
58
+
elm.propToUse = prop;
59
+
try {
60
+
document.body.appendChild(elm);
61
+
} catch (err) {
62
+
// In synthetic custom element lifecycle, the error is thrown synchronously on `appendChild`
63
+
caughtError = err;
64
+
}
46
65
47
-
await Promise.resolve();
66
+
await Promise.resolve();
48
67
49
-
if (process.env.NATIVE_SHADOW && process.env.DISABLE_STATIC_CONTENT_OPTIMIZATION) {
50
-
// If we're rendering in native shadow and the static content optimization is disabled,
51
-
// then there's no problem with non-string stylesheet tokens because they are only rendered
52
-
// as class attribute values using either `classList` or `setAttribute` (and this only applies
53
-
// when `*.scoped.css` is being used).
54
-
expect(elm.shadowRoot.children.length).toBe(1);
55
-
} else {
56
-
expect(elm.shadowRoot.children.length).toBe(0); // does not render
68
+
if (
69
+
process.env.NATIVE_SHADOW &&
70
+
process.env.DISABLE_STATIC_CONTENT_OPTIMIZATION
71
+
) {
72
+
// If we're rendering in native shadow and the static content optimization is disabled,
73
+
// then there's no problem with non-string stylesheet tokens because they are only rendered
74
+
// as class attribute values using either `classList` or `setAttribute` (and this only applies
75
+
// when `*.scoped.css` is being used).
76
+
expect(elm.shadowRoot.children.length).toBe(1);
77
+
} else {
78
+
expect(elm.shadowRoot.children.length).toBe(0); // does not render
57
79
58
-
expect(caughtError).not.toBeUndefined();
59
-
expect(caughtError.message).toMatch(
60
-
/stylesheet token must be a string|Failed to execute 'setAttribute'|Invalid qualified name|String contains an invalid character|The string contains invalid characters/
61
-
);
80
+
expect(caughtError).not.toBeUndefined();
81
+
expect(caughtError.message).toMatch(
82
+
/stylesheet token must be a valid string|Failed to execute 'setAttribute'|Invalid qualified name|String contains an invalid character|The string contains invalid characters/
83
+
);
62
84
63
-
if (process.env.NODE_ENV === 'production') {
64
-
// no warnings in prod mode
65
-
expect(logger).not.toHaveBeenCalled();
66
-
} else {
67
-
// dev mode
68
-
expect(logger).toHaveBeenCalledTimes(1);
69
-
expect(logger.calls.allArgs()[0]).toMatch(
70
-
new RegExp(`Mutating the "${prop}" property on a template is deprecated`)
71
-
);
72
-
}
73
-
}
85
+
if (process.env.NODE_ENV === 'production') {
86
+
// no warnings in prod mode
87
+
expect(logger).not.toHaveBeenCalled();
88
+
} else {
89
+
// dev mode
90
+
expect(logger).toHaveBeenCalledTimes(1);
91
+
expect(logger.calls.allArgs()[0]).toMatch(
92
+
new RegExp(
93
+
`Mutating the "${prop}" property on a template is deprecated`
0 commit comments