@lwc/ssr-runtime 8.1.1 → 8.1.3

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @lwc/ssr-runtime
2
+
3
+ This is an experimental package containing a runtime for server-side rendering components. It may break at any point.
package/dist/index.cjs.js CHANGED
@@ -5,12 +5,67 @@
5
5
 
6
6
  Object.defineProperty(exports, '__esModule', { value: true });
7
7
 
8
+ /*
9
+ * Copyright (c) 2024, Salesforce, Inc.
10
+ * All rights reserved.
11
+ * SPDX-License-Identifier: MIT
12
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
13
+ */
14
+ /**
15
+ * Per the HTML spec on restrictions for "raw text elements" like `<style>`:
16
+ *
17
+ * > The text in raw text and escapable raw text elements must not contain any occurrences of the string
18
+ * > "</" (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of
19
+ * > the element followed by one of:
20
+ * > - U+0009 CHARACTER TABULATION (tab)
21
+ * > - U+000A LINE FEED (LF)
22
+ * > - U+000C FORM FEED (FF)
23
+ * > - U+000D CARRIAGE RETURN (CR)
24
+ * > - U+0020 SPACE
25
+ * > - U+003E GREATER-THAN SIGN (>), or
26
+ * > - U+002F SOLIDUS (/)
27
+ * @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
28
+ */
29
+ const INVALID_STYLE_CONTENT = /<\/style[\t\n\f\r >/]/i;
30
+ /**
31
+ * The text content inside `<style>` is a special case. It is _only_ rendered by the LWC engine itself; `<style>` tags
32
+ * are disallowed inside of HTML templates.
33
+ *
34
+ * The `<style>` tag is unusual in how it's defined in HTML. Like `<script>`, it is considered a "raw text element,"
35
+ * which means that it is parsed as raw text, but certain character sequences are disallowed, namely to avoid XSS
36
+ * attacks like `</style><script>alert("pwned")</script>`.
37
+ *
38
+ * This also means that we cannot use "normal" HTML escaping inside `<style>` tags, e.g. we cannot use `&lt;`,
39
+ * `&gt;`, etc., because these are treated as-is by the HTML parser.
40
+ *
41
+ *
42
+ * @param contents CSS source to validate
43
+ * @throws Throws if the contents provided are not valid.
44
+ * @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
45
+ * @see https://github.com/salesforce/lwc/issues/3439
46
+ * @example
47
+ * validateStyleTextContents('div { color: red }') // Ok
48
+ * validateStyleTextContents('</style><script>alert("pwned")</script>') // Throws
49
+ */
50
+ function validateStyleTextContents(contents) {
51
+ if (INVALID_STYLE_CONTENT.test(contents)) {
52
+ throw new Error('CSS contains unsafe characters and cannot be serialized inside a style element');
53
+ }
54
+ }
55
+
8
56
  /*
9
57
  * Copyright (c) 2024, salesforce.com, inc.
10
58
  * All rights reserved.
11
59
  * SPDX-License-Identifier: MIT
12
60
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
13
61
  */
62
+ // At runtime, we don't have access to the DOM, so we don't want TypeScript to allow accessing DOM
63
+ // globals. However, we're mimicking DOM functionality here, so we *do* want access to DOM types.
64
+ // To access the real DOM types when writing new code, uncomment the line below and comment out the
65
+ // stub types. Switch them back when you're done to validate that you're not accidentally using
66
+ // DOM globals. IMPORTANT: The comment below is a "triple slash directive", it must start with ///
67
+ // and be located before import statements.
68
+ // /// <reference lib="dom" />
14
69
  const MULTI_SPACE = /\s+/g;
15
70
  class ClassList {
16
71
  constructor(el) {
@@ -61,6 +116,24 @@ class ClassList {
61
116
  this.el.className = Array.from(set).join(' ');
62
117
  return set.has(classNameToToggle);
63
118
  }
119
+ get value() {
120
+ return this.el.className;
121
+ }
122
+ toString() {
123
+ return this.el.className;
124
+ }
125
+ item(_index) {
126
+ throw new Error('Method "item" not implemented.');
127
+ }
128
+ supports(_token) {
129
+ throw new Error('Method "supports" not implemented.');
130
+ }
131
+ forEach(_callbackfn, _thisArg) {
132
+ throw new Error('Method "forEach" not implemented.');
133
+ }
134
+ get length() {
135
+ throw new Error('Property "length" not implemented.');
136
+ }
64
137
  }
65
138
  class LightningElement {
66
139
  constructor(propsAvailableAtConstruction) {
@@ -103,8 +176,89 @@ class LightningElement {
103
176
  return (this.__classList = new ClassList(this));
104
177
  }
105
178
  getAttribute(attrName) {
106
- const value = this.__attrs?.[attrName];
107
- return value === true ? '' : (value ?? null);
179
+ return this.__attrs[attrName] ?? null;
180
+ }
181
+ setAttribute(attrName, value) {
182
+ this.__attrs[attrName] = String(value);
183
+ }
184
+ hasAttribute(attrName) {
185
+ return Boolean(this.__attrs && attrName in this.__attrs);
186
+ }
187
+ removeAttribute(attrName) {
188
+ this.__attrs[attrName] = null;
189
+ }
190
+ addEventListener(_type, _listener, _options) {
191
+ // noop
192
+ }
193
+ removeEventListener(_type, _listener, _options) {
194
+ // noop
195
+ }
196
+ // ----------------------------------------------------------- //
197
+ // Props/methods explicitly not available in this environment //
198
+ // Getters are named "get*" for parity with @lwc/engine-server //
199
+ // ----------------------------------------------------------- //
200
+ get children() {
201
+ throw new TypeError('"getChildren" is not supported in this environment');
202
+ }
203
+ get childNodes() {
204
+ throw new TypeError('"getChildNodes" is not supported in this environment');
205
+ }
206
+ get firstChild() {
207
+ throw new TypeError('"getFirstChild" is not supported in this environment');
208
+ }
209
+ get firstElementChild() {
210
+ throw new TypeError('"getFirstElementChild" is not supported in this environment');
211
+ }
212
+ get hostElement() {
213
+ // Intentionally different to match @lwc/engine-*core*
214
+ throw new TypeError('this.hostElement is not supported in this environment');
215
+ }
216
+ get lastChild() {
217
+ throw new TypeError('"getLastChild" is not supported in this environment');
218
+ }
219
+ get lastElementChild() {
220
+ throw new TypeError('"getLastElementChild" is not supported in this environment');
221
+ }
222
+ get ownerDocument() {
223
+ // Intentionally not "get*" to match @lwc/engine-server
224
+ throw new TypeError('"ownerDocument" is not supported in this environment');
225
+ }
226
+ get style() {
227
+ // Intentionally not "get*" to match @lwc/engine-server
228
+ throw new TypeError('"style" is not supported in this environment');
229
+ }
230
+ attachInternals() {
231
+ throw new TypeError('"attachInternals" is not supported in this environment');
232
+ }
233
+ dispatchEvent(_event) {
234
+ throw new TypeError('"dispatchEvent" is not supported in this environment');
235
+ }
236
+ getBoundingClientRect() {
237
+ throw new TypeError('"getBoundingClientRect" is not supported in this environment');
238
+ }
239
+ getElementsByClassName(_classNames) {
240
+ throw new TypeError('"getElementsByClassName" is not supported in this environment');
241
+ }
242
+ getElementsByTagName(_qualifiedName) {
243
+ throw new TypeError('"getElementsByTagName" is not supported in this environment');
244
+ }
245
+ querySelector(_selectors) {
246
+ throw new TypeError('"querySelector" is not supported in this environment');
247
+ }
248
+ querySelectorAll(_selectors) {
249
+ throw new TypeError('"querySelectorAll" is not supported in this environment');
250
+ }
251
+ getAttributeNS(_namespace, _localName) {
252
+ throw new Error('Method "getAttributeNS" not implemented.');
253
+ }
254
+ hasAttributeNS(_namespace, _localName) {
255
+ throw new Error('Method "hasAttributeNS" not implemented.');
256
+ }
257
+ removeAttributeNS(_namespace, _localName) {
258
+ throw new Error('Method "removeAttributeNS" not implemented.');
259
+ }
260
+ setAttributeNS(_namespace, _qualifiedName, _value) {
261
+ throw new Error('Method "setAttributeNS" not implemented.');
108
262
  }
109
263
  }
110
264
  const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&amp;').replaceAll('"', '&quot;');
@@ -113,13 +267,11 @@ function* renderAttrs(attrs) {
113
267
  return;
114
268
  }
115
269
  for (const [key, val] of Object.entries(attrs)) {
116
- if (val) {
117
- if (typeof val === 'string') {
118
- yield ` ${key}="${escapeAttrVal(val)}"`;
119
- }
120
- else {
121
- yield ` ${key}`;
122
- }
270
+ if (typeof val === 'string') {
271
+ yield val === '' ? ` ${key}` : ` ${key}="${escapeAttrVal(val)}"`;
272
+ }
273
+ else if (val === null) {
274
+ return '';
123
275
  }
124
276
  }
125
277
  }
@@ -140,5 +292,6 @@ exports.LightningElement = LightningElement;
140
292
  exports.fallbackTmpl = fallbackTmpl;
141
293
  exports.renderAttrs = renderAttrs;
142
294
  exports.serverSideRenderComponent = serverSideRenderComponent;
143
- /** version: 8.1.1 */
295
+ exports.validateStyleTextContents = validateStyleTextContents;
296
+ /** version: 8.1.3 */
144
297
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;AAKG;AAEH,MAAM,WAAW,GAAG,MAAM,CAAC;AAM3B,MAAM,SAAS,CAAA;AAGX,IAAA,WAAA,CAAY,EAAoB,EAAA;AAC5B,QAAA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;KAChB;IAED,GAAG,CAAC,GAAG,aAAuB,EAAA;AAC1B,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;AACpC,QAAA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,QAAA,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;AACtC,YAAA,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;SACzB;AACD,QAAA,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACjD;AAED,IAAA,QAAQ,CAAC,SAAiB,EAAA;AACtB,QAAA,MAAM,mBAAmB,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;QAC9C,OAAO,mBAAmB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;KACrE;IAED,MAAM,CAAC,GAAG,kBAA4B,EAAA;AAClC,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;AACpC,QAAA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,QAAA,KAAK,MAAM,YAAY,I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QAAiB,EACjB,GAAgC,EAChC,SAAkB,EAAA;AAElB,IAAA,IAAI,GAAG,CAAC,UAAU,KAAK,OAAO,EAAE;AAC5B,QAAA,MAAM,6CAA6C,CAAC;KACvD;AACL,CAAC;AASM,eAAe,yBAAyB,CAC3C,OAAe,EACf,sBAAwC,EACxC,KAA0B,EAAA;IAE1B,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,IAAA,WAAW,MAAM,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;QAC5E,MAAM,IAAI,OAAO,CAAC;KACrB;AAED,IAAA,OAAO,MAAM,CAAC;AAClB;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/validate-style-text-contents.ts","../src/index.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;;;;AAAA;;;;;AAKG;AAEH;;;;;;;;;;;;;;AAcG;AACH,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,yBAAyB,CAAC,QAAgB,EAAA;AACtD,IAAA,IAAI,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;AACtC,QAAA,MAAM,IAAI,KAAK,CACX,gFAAgF,CACnF,CAAC;KACL;AACL;;AClDA;;;;;AAKG;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AAUA,MAAM,WAAW,GAAG,MAAM,CAAC;AAM3B,MAAM,SAAS,CAAA;AAGX,IAAA,WAAA,CAAY,EAAoB,EAAA;AAC5B,QAAA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;KAChB;IAED,GAAG,CAAC,GAAG,aAAuB,EAAA;AAC1B,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;AACpC,QAAA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,C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ACzB,MAAe,EACf,MAAe,EACf,QAAiB,EACjB,GAAgC,EAChC,SAAkB,EAAA;AAElB,IAAA,IAAI,GAAG,CAAC,UAAU,KAAK,OAAO,EAAE;AAC5B,QAAA,MAAM,6CAA6C,CAAC;KACvD;AACL,CAAC;AASM,eAAe,yBAAyB,CAC3C,OAAe,EACf,sBAAwC,EACxC,KAA0B,EAAA;IAE1B,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,IAAA,WAAW,MAAM,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;QAC5E,MAAM,IAAI,OAAO,CAAC;KACrB;AAED,IAAA,OAAO,MAAM,CAAC;AAClB;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,12 @@
1
- type Attributes = Record<string, string | true>;
1
+ export { validateStyleTextContents } from './validate-style-text-contents';
2
+ type DOMTokenList = object;
3
+ type EventListenerOrEventListenerObject = unknown;
4
+ type AddEventListenerOptions = unknown;
5
+ type EventListenerOptions = unknown;
6
+ type ShadowRoot = unknown;
7
+ type Attributes = Record<string, string | null>;
2
8
  type LightningElementConstructor = typeof LightningElement;
3
- declare class ClassList {
9
+ declare class ClassList implements DOMTokenList {
4
10
  el: LightningElement;
5
11
  constructor(el: LightningElement);
6
12
  add(...newClassNames: string[]): void;
@@ -8,20 +14,65 @@ declare class ClassList {
8
14
  remove(...classNamesToRemove: string[]): void;
9
15
  replace(oldClassName: string, newClassName: string): boolean;
10
16
  toggle(classNameToToggle: string, force?: boolean): boolean;
17
+ get value(): string;
18
+ toString(): string;
19
+ [index: number]: never;
20
+ item(_index: number): string | null;
21
+ supports(_token: string): boolean;
22
+ forEach(_callbackfn: (value: string, key: number, parent: DOMTokenList) => void, _thisArg?: any): void;
23
+ get length(): number;
11
24
  }
12
- export declare class LightningElement {
25
+ interface PropsAvailableAtConstruction {
26
+ tagName: string;
27
+ }
28
+ export declare class LightningElement implements PropsAvailableAtConstruction {
13
29
  static renderMode?: 'light' | 'shadow';
14
30
  isConnected: boolean;
15
31
  className: string;
16
- __attrs?: Attributes;
17
- __classList: ClassList | null;
18
- constructor(propsAvailableAtConstruction: Record<string, any>);
19
- __internal__setState(props: Record<string, any>, reflectedProps: string[], attrs: Record<string, any>): void;
32
+ private __attrs;
33
+ private __classList;
34
+ tagName: string;
35
+ constructor(propsAvailableAtConstruction: PropsAvailableAtConstruction & Record<string, unknown>);
36
+ private __internal__setState;
20
37
  get classList(): ClassList;
21
38
  getAttribute(attrName: string): string | null;
39
+ setAttribute(attrName: string, value: string | null): void;
40
+ hasAttribute(attrName: string): boolean;
41
+ removeAttribute(attrName: string): void;
42
+ addEventListener(_type: string, _listener: EventListenerOrEventListenerObject, _options?: boolean | AddEventListenerOptions): void;
43
+ removeEventListener(_type: string, _listener: EventListenerOrEventListenerObject, _options?: boolean | EventListenerOptions): void;
44
+ get children(): never;
45
+ get childNodes(): never;
46
+ get firstChild(): never;
47
+ get firstElementChild(): never;
48
+ get hostElement(): never;
49
+ get lastChild(): never;
50
+ get lastElementChild(): never;
51
+ get ownerDocument(): never;
52
+ get style(): never;
53
+ attachInternals(): never;
54
+ dispatchEvent(_event: Event): never;
55
+ getBoundingClientRect(): never;
56
+ getElementsByClassName(_classNames: string): never;
57
+ getElementsByTagName(_qualifiedName: unknown): never;
58
+ querySelector(_selectors: string): never;
59
+ querySelectorAll(_selectors: string): never;
60
+ accessKey?: string;
61
+ dir?: string;
62
+ draggable?: boolean;
63
+ hidden?: boolean;
64
+ id?: string;
65
+ lang?: string;
66
+ shadowRoot?: ShadowRoot | null;
67
+ spellcheck?: boolean;
68
+ tabIndex?: number;
69
+ title?: string;
70
+ getAttributeNS(_namespace: string | null, _localName: string): string | null;
71
+ hasAttributeNS(_namespace: string | null, _localName: string): boolean;
72
+ removeAttributeNS(_namespace: string | null, _localName: string): void;
73
+ setAttributeNS(_namespace: string | null, _qualifiedName: string, _value: string): void;
22
74
  }
23
- export declare function renderAttrs(attrs: Attributes): Generator<string, void, unknown>;
75
+ export declare function renderAttrs(attrs: Attributes): Generator<string, "" | undefined, unknown>;
24
76
  export declare function fallbackTmpl(_props: unknown, _attrs: unknown, _slotted: unknown, Cmp: LightningElementConstructor, _instance: unknown): Generator<string, void, unknown>;
25
77
  export type GenerateMarkupFn = (tagName: string, props: Record<string, any> | null, attrs: Attributes | null, slotted: Record<number | string, AsyncGenerator<string>> | null) => AsyncGenerator<string>;
26
78
  export declare function serverSideRenderComponent(tagName: string, compiledGenerateMarkup: GenerateMarkupFn, props: Record<string, any>): Promise<string>;
27
- export {};
package/dist/index.js CHANGED
@@ -1,12 +1,67 @@
1
1
  /**
2
2
  * Copyright (c) 2024 Salesforce, Inc.
3
3
  */
4
+ /*
5
+ * Copyright (c) 2024, Salesforce, Inc.
6
+ * All rights reserved.
7
+ * SPDX-License-Identifier: MIT
8
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9
+ */
10
+ /**
11
+ * Per the HTML spec on restrictions for "raw text elements" like `<style>`:
12
+ *
13
+ * > The text in raw text and escapable raw text elements must not contain any occurrences of the string
14
+ * > "</" (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of
15
+ * > the element followed by one of:
16
+ * > - U+0009 CHARACTER TABULATION (tab)
17
+ * > - U+000A LINE FEED (LF)
18
+ * > - U+000C FORM FEED (FF)
19
+ * > - U+000D CARRIAGE RETURN (CR)
20
+ * > - U+0020 SPACE
21
+ * > - U+003E GREATER-THAN SIGN (>), or
22
+ * > - U+002F SOLIDUS (/)
23
+ * @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
24
+ */
25
+ const INVALID_STYLE_CONTENT = /<\/style[\t\n\f\r >/]/i;
26
+ /**
27
+ * The text content inside `<style>` is a special case. It is _only_ rendered by the LWC engine itself; `<style>` tags
28
+ * are disallowed inside of HTML templates.
29
+ *
30
+ * The `<style>` tag is unusual in how it's defined in HTML. Like `<script>`, it is considered a "raw text element,"
31
+ * which means that it is parsed as raw text, but certain character sequences are disallowed, namely to avoid XSS
32
+ * attacks like `</style><script>alert("pwned")</script>`.
33
+ *
34
+ * This also means that we cannot use "normal" HTML escaping inside `<style>` tags, e.g. we cannot use `&lt;`,
35
+ * `&gt;`, etc., because these are treated as-is by the HTML parser.
36
+ *
37
+ *
38
+ * @param contents CSS source to validate
39
+ * @throws Throws if the contents provided are not valid.
40
+ * @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
41
+ * @see https://github.com/salesforce/lwc/issues/3439
42
+ * @example
43
+ * validateStyleTextContents('div { color: red }') // Ok
44
+ * validateStyleTextContents('</style><script>alert("pwned")</script>') // Throws
45
+ */
46
+ function validateStyleTextContents(contents) {
47
+ if (INVALID_STYLE_CONTENT.test(contents)) {
48
+ throw new Error('CSS contains unsafe characters and cannot be serialized inside a style element');
49
+ }
50
+ }
51
+
4
52
  /*
5
53
  * Copyright (c) 2024, salesforce.com, inc.
6
54
  * All rights reserved.
7
55
  * SPDX-License-Identifier: MIT
8
56
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
9
57
  */
58
+ // At runtime, we don't have access to the DOM, so we don't want TypeScript to allow accessing DOM
59
+ // globals. However, we're mimicking DOM functionality here, so we *do* want access to DOM types.
60
+ // To access the real DOM types when writing new code, uncomment the line below and comment out the
61
+ // stub types. Switch them back when you're done to validate that you're not accidentally using
62
+ // DOM globals. IMPORTANT: The comment below is a "triple slash directive", it must start with ///
63
+ // and be located before import statements.
64
+ // /// <reference lib="dom" />
10
65
  const MULTI_SPACE = /\s+/g;
11
66
  class ClassList {
12
67
  constructor(el) {
@@ -57,6 +112,24 @@ class ClassList {
57
112
  this.el.className = Array.from(set).join(' ');
58
113
  return set.has(classNameToToggle);
59
114
  }
115
+ get value() {
116
+ return this.el.className;
117
+ }
118
+ toString() {
119
+ return this.el.className;
120
+ }
121
+ item(_index) {
122
+ throw new Error('Method "item" not implemented.');
123
+ }
124
+ supports(_token) {
125
+ throw new Error('Method "supports" not implemented.');
126
+ }
127
+ forEach(_callbackfn, _thisArg) {
128
+ throw new Error('Method "forEach" not implemented.');
129
+ }
130
+ get length() {
131
+ throw new Error('Property "length" not implemented.');
132
+ }
60
133
  }
61
134
  class LightningElement {
62
135
  constructor(propsAvailableAtConstruction) {
@@ -99,8 +172,89 @@ class LightningElement {
99
172
  return (this.__classList = new ClassList(this));
100
173
  }
101
174
  getAttribute(attrName) {
102
- const value = this.__attrs?.[attrName];
103
- return value === true ? '' : (value ?? null);
175
+ return this.__attrs[attrName] ?? null;
176
+ }
177
+ setAttribute(attrName, value) {
178
+ this.__attrs[attrName] = String(value);
179
+ }
180
+ hasAttribute(attrName) {
181
+ return Boolean(this.__attrs && attrName in this.__attrs);
182
+ }
183
+ removeAttribute(attrName) {
184
+ this.__attrs[attrName] = null;
185
+ }
186
+ addEventListener(_type, _listener, _options) {
187
+ // noop
188
+ }
189
+ removeEventListener(_type, _listener, _options) {
190
+ // noop
191
+ }
192
+ // ----------------------------------------------------------- //
193
+ // Props/methods explicitly not available in this environment //
194
+ // Getters are named "get*" for parity with @lwc/engine-server //
195
+ // ----------------------------------------------------------- //
196
+ get children() {
197
+ throw new TypeError('"getChildren" is not supported in this environment');
198
+ }
199
+ get childNodes() {
200
+ throw new TypeError('"getChildNodes" is not supported in this environment');
201
+ }
202
+ get firstChild() {
203
+ throw new TypeError('"getFirstChild" is not supported in this environment');
204
+ }
205
+ get firstElementChild() {
206
+ throw new TypeError('"getFirstElementChild" is not supported in this environment');
207
+ }
208
+ get hostElement() {
209
+ // Intentionally different to match @lwc/engine-*core*
210
+ throw new TypeError('this.hostElement is not supported in this environment');
211
+ }
212
+ get lastChild() {
213
+ throw new TypeError('"getLastChild" is not supported in this environment');
214
+ }
215
+ get lastElementChild() {
216
+ throw new TypeError('"getLastElementChild" is not supported in this environment');
217
+ }
218
+ get ownerDocument() {
219
+ // Intentionally not "get*" to match @lwc/engine-server
220
+ throw new TypeError('"ownerDocument" is not supported in this environment');
221
+ }
222
+ get style() {
223
+ // Intentionally not "get*" to match @lwc/engine-server
224
+ throw new TypeError('"style" is not supported in this environment');
225
+ }
226
+ attachInternals() {
227
+ throw new TypeError('"attachInternals" is not supported in this environment');
228
+ }
229
+ dispatchEvent(_event) {
230
+ throw new TypeError('"dispatchEvent" is not supported in this environment');
231
+ }
232
+ getBoundingClientRect() {
233
+ throw new TypeError('"getBoundingClientRect" is not supported in this environment');
234
+ }
235
+ getElementsByClassName(_classNames) {
236
+ throw new TypeError('"getElementsByClassName" is not supported in this environment');
237
+ }
238
+ getElementsByTagName(_qualifiedName) {
239
+ throw new TypeError('"getElementsByTagName" is not supported in this environment');
240
+ }
241
+ querySelector(_selectors) {
242
+ throw new TypeError('"querySelector" is not supported in this environment');
243
+ }
244
+ querySelectorAll(_selectors) {
245
+ throw new TypeError('"querySelectorAll" is not supported in this environment');
246
+ }
247
+ getAttributeNS(_namespace, _localName) {
248
+ throw new Error('Method "getAttributeNS" not implemented.');
249
+ }
250
+ hasAttributeNS(_namespace, _localName) {
251
+ throw new Error('Method "hasAttributeNS" not implemented.');
252
+ }
253
+ removeAttributeNS(_namespace, _localName) {
254
+ throw new Error('Method "removeAttributeNS" not implemented.');
255
+ }
256
+ setAttributeNS(_namespace, _qualifiedName, _value) {
257
+ throw new Error('Method "setAttributeNS" not implemented.');
104
258
  }
105
259
  }
106
260
  const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&amp;').replaceAll('"', '&quot;');
@@ -109,13 +263,11 @@ function* renderAttrs(attrs) {
109
263
  return;
110
264
  }
111
265
  for (const [key, val] of Object.entries(attrs)) {
112
- if (val) {
113
- if (typeof val === 'string') {
114
- yield ` ${key}="${escapeAttrVal(val)}"`;
115
- }
116
- else {
117
- yield ` ${key}`;
118
- }
266
+ if (typeof val === 'string') {
267
+ yield val === '' ? ` ${key}` : ` ${key}="${escapeAttrVal(val)}"`;
268
+ }
269
+ else if (val === null) {
270
+ return '';
119
271
  }
120
272
  }
121
273
  }
@@ -132,6 +284,6 @@ async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props)
132
284
  return markup;
133
285
  }
134
286
 
135
- export { LightningElement, fallbackTmpl, renderAttrs, serverSideRenderComponent };
136
- /** version: 8.1.1 */
287
+ export { LightningElement, fallbackTmpl, renderAttrs, serverSideRenderComponent, validateStyleTextContents };
288
+ /** version: 8.1.3 */
137
289
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAEH,MAAM,WAAW,GAAG,MAAM,CAAC;AAM3B,MAAM,SAAS,CAAA;AAGX,IAAA,WAAA,CAAY,EAAoB,EAAA;AAC5B,QAAA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;KAChB;IAED,GAAG,CAAC,GAAG,aAAuB,EAAA;AAC1B,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;AACpC,QAAA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,QAAA,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;AACtC,YAAA,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;SACzB;AACD,QAAA,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACjD;AAED,IAAA,QAAQ,CAAC,SAAiB,EAAA;AACtB,QAAA,MAAM,mBAAmB,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;QAC9C,OAAO,mBAAmB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;KACrE;IAED,MAAM,CAAC,G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,EAAE;gBACzB,MAAM,CAAA,CAAA,EAAI,GAAG,CAAK,EAAA,EAAA,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC;aAC3C;iBAAM;gBACH,MAAM,CAAA,CAAA,EAAI,GAAG,CAAA,CAAE,CAAC;aACnB;SACJ;KACJ;AACL,CAAC;AAEc,UAAE,YAAY,CACzB,MAAe,EACf,MAAe,EACf,QAAiB,EACjB,GAAgC,EAChC,SAAkB,EAAA;AAElB,IAAA,IAAI,GAAG,CAAC,UAAU,KAAK,OAAO,EAAE;AAC5B,QAAA,MAAM,6CAA6C,CAAC;KACvD;AACL,CAAC;AASM,eAAe,yBAAyB,CAC3C,OAAe,EACf,sBAAwC,EACxC,KAA0B,EAAA;IAE1B,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,IAAA,WAAW,MAAM,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;QAC5E,MAAM,IAAI,OAAO,CAAC;KACrB;AAED,IAAA,OAAO,MAAM,CAAC;AAClB;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/validate-style-text-contents.ts","../src/index.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAEH;;;;;;;;;;;;;;AAcG;AACH,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,yBAAyB,CAAC,QAAgB,EAAA;AACtD,IAAA,IAAI,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;AACtC,QAAA,MAAM,IAAI,KAAK,CACX,gFAAgF,CACnF,CAAC;KACL;AACL;;AClDA;;;;;AAKG;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AAUA,MAAM,WAAW,GAAG,MAAM,CAAC;AAM3B,MAAM,SAAS,CAAA;AAGX,IAAA,WAAA,CAAY,EAAoB,EAAA;AAC5B,QAAA,IAAI,CAAC,E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A,EAAI,GAAG,CAAE,CAAA,GAAG,CAAA,CAAA,EAAI,GAAG,CAAK,EAAA,EAAA,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC;SACpE;AAAM,aAAA,IAAI,GAAG,KAAK,IAAI,EAAE;AACrB,YAAA,OAAO,EAAE,CAAC;SACb;KACJ;AACL,CAAC;AAEc,UAAE,YAAY,CACzB,MAAe,EACf,MAAe,EACf,QAAiB,EACjB,GAAgC,EAChC,SAAkB,EAAA;AAElB,IAAA,IAAI,GAAG,CAAC,UAAU,KAAK,OAAO,EAAE;AAC5B,QAAA,MAAM,6CAA6C,CAAC;KACvD;AACL,CAAC;AASM,eAAe,yBAAyB,CAC3C,OAAe,EACf,sBAAwC,EACxC,KAA0B,EAAA;IAE1B,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,IAAA,WAAW,MAAM,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;QAC5E,MAAM,IAAI,OAAO,CAAC;KACrB;AAED,IAAA,OAAO,MAAM,CAAC;AAClB;;;;;;;"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The text content inside `<style>` is a special case. It is _only_ rendered by the LWC engine itself; `<style>` tags
3
+ * are disallowed inside of HTML templates.
4
+ *
5
+ * The `<style>` tag is unusual in how it's defined in HTML. Like `<script>`, it is considered a "raw text element,"
6
+ * which means that it is parsed as raw text, but certain character sequences are disallowed, namely to avoid XSS
7
+ * attacks like `</style><script>alert("pwned")</script>`.
8
+ *
9
+ * This also means that we cannot use "normal" HTML escaping inside `<style>` tags, e.g. we cannot use `&lt;`,
10
+ * `&gt;`, etc., because these are treated as-is by the HTML parser.
11
+ *
12
+ *
13
+ * @param contents CSS source to validate
14
+ * @throws Throws if the contents provided are not valid.
15
+ * @see https://html.spec.whatwg.org/multipage/syntax.html#raw-text-elements
16
+ * @see https://github.com/salesforce/lwc/issues/3439
17
+ * @example
18
+ * validateStyleTextContents('div { color: red }') // Ok
19
+ * validateStyleTextContents('</style><script>alert("pwned")</script>') // Throws
20
+ */
21
+ export declare function validateStyleTextContents(contents: string): void;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
5
5
  ],
6
6
  "name": "@lwc/ssr-runtime",
7
- "version": "8.1.1",
7
+ "version": "8.1.3",
8
8
  "description": "Runtime complement to @lwc/ssr-compiler",
9
9
  "keywords": [
10
10
  "lwc",