@lwc/ssr-compiler
Advanced tools
Comparing version
@@ -11,2 +11,3 @@ /** | ||
var meriyah = require('meriyah'); | ||
var shared = require('@lwc/shared'); | ||
var acorn = require('acorn'); | ||
@@ -17,147 +18,3 @@ var immer = require('immer'); | ||
/** | ||
* Copyright (c) 2024 Salesforce, Inc. | ||
*/ | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
/** | ||
* | ||
* @param value | ||
* @param msg | ||
*/ | ||
/* | ||
* Copyright (c) 2024, Salesforce, Inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
const { | ||
/** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */ | ||
assign, | ||
/** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */ | ||
create, | ||
/** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */ | ||
defineProperties, | ||
/** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */ | ||
defineProperty, | ||
/** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */ | ||
entries, | ||
/** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */ | ||
freeze, | ||
/** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */ | ||
getOwnPropertyDescriptor, | ||
/** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */ | ||
getOwnPropertyDescriptors, | ||
/** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */ | ||
getOwnPropertyNames, | ||
/** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */ | ||
getPrototypeOf, | ||
/** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */ | ||
hasOwnProperty, | ||
/** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */ | ||
isFrozen, | ||
/** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */ | ||
keys, | ||
/** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */ | ||
seal, | ||
/** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */ | ||
setPrototypeOf, } = Object; | ||
// For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even | ||
// though it works fine for one, e.g. isArray), so comments for these are added to the export | ||
// statement, rather than this declaration. | ||
const { concat: ArrayConcat, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly! | ||
} = Array.prototype; | ||
// No JSDocs here - see comment for Array.prototype | ||
const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype; | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
/** | ||
* According to the following list, there are 48 aria attributes of which two (ariaDropEffect and | ||
* ariaGrabbed) are deprecated: | ||
* https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes | ||
* | ||
* The above list of 46 aria attributes is consistent with the following resources: | ||
* https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060 | ||
* https://wicg.github.io/aom/spec/aria-reflection.html | ||
* | ||
* NOTE: If you update this list, please update test files that implicitly reference this list! | ||
* Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages. | ||
*/ | ||
const AriaPropertyNames = [ | ||
'ariaActiveDescendant', | ||
'ariaAtomic', | ||
'ariaAutoComplete', | ||
'ariaBusy', | ||
'ariaChecked', | ||
'ariaColCount', | ||
'ariaColIndex', | ||
'ariaColIndexText', | ||
'ariaColSpan', | ||
'ariaControls', | ||
'ariaCurrent', | ||
'ariaDescribedBy', | ||
'ariaDescription', | ||
'ariaDetails', | ||
'ariaDisabled', | ||
'ariaErrorMessage', | ||
'ariaExpanded', | ||
'ariaFlowTo', | ||
'ariaHasPopup', | ||
'ariaHidden', | ||
'ariaInvalid', | ||
'ariaKeyShortcuts', | ||
'ariaLabel', | ||
'ariaLabelledBy', | ||
'ariaLevel', | ||
'ariaLive', | ||
'ariaModal', | ||
'ariaMultiLine', | ||
'ariaMultiSelectable', | ||
'ariaOrientation', | ||
'ariaOwns', | ||
'ariaPlaceholder', | ||
'ariaPosInSet', | ||
'ariaPressed', | ||
'ariaReadOnly', | ||
'ariaRelevant', | ||
'ariaRequired', | ||
'ariaRoleDescription', | ||
'ariaRowCount', | ||
'ariaRowIndex', | ||
'ariaRowIndexText', | ||
'ariaRowSpan', | ||
'ariaSelected', | ||
'ariaSetSize', | ||
'ariaSort', | ||
'ariaValueMax', | ||
'ariaValueMin', | ||
'ariaValueNow', | ||
'ariaValueText', | ||
'ariaBrailleLabel', | ||
'ariaBrailleRoleDescription', | ||
'role', | ||
]; | ||
const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (() => { | ||
const AriaAttrNameToPropNameMap = create(null); | ||
const AriaPropNameToAttrNameMap = create(null); | ||
// Synthetic creation of all AOM property descriptors for Custom Elements | ||
forEach.call(AriaPropertyNames, (propName) => { | ||
const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-')); | ||
AriaAttrNameToPropNameMap[attrName] = propName; | ||
AriaPropNameToAttrNameMap[propName] = attrName; | ||
}); | ||
return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap }; | ||
})(); | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
@@ -168,101 +25,3 @@ * All rights reserved. | ||
*/ | ||
const reservedKeywords = new Set([ | ||
'NaN', | ||
'arguments', | ||
'break', | ||
'case', | ||
'catch', | ||
'class', | ||
'const', | ||
'continue', | ||
'debugger', | ||
'default', | ||
'delete', | ||
'do', | ||
'else', | ||
'enum', | ||
'eval', | ||
'export', | ||
'extends', | ||
'false', | ||
'finally', | ||
'for', | ||
'function', | ||
'if', | ||
'implements', | ||
'import', | ||
'in', | ||
'instanceof', | ||
'interface', | ||
'let', | ||
'new', | ||
'null', | ||
'package', | ||
'private', | ||
'protected', | ||
'public', | ||
'return', | ||
'static', | ||
'super', | ||
'switch', | ||
'this', | ||
'throw', | ||
'true', | ||
'try', | ||
'typeof', | ||
'undefined', | ||
'var', | ||
'void', | ||
'while', | ||
'with', | ||
'yield', | ||
]); | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
// Void elements are elements that self-close even without an explicit solidus (slash), | ||
// e.g. `</tagName>` or `<tagName />`. For instance, `<meta>` closes on its own; no need for a slash. | ||
// These only come from HTML; there are no void elements in the SVG or MathML namespaces. | ||
// See: https://html.spec.whatwg.org/multipage/syntax.html#syntax-tags | ||
const VOID_ELEMENTS = [ | ||
'area', | ||
'base', | ||
'br', | ||
'col', | ||
'embed', | ||
'hr', | ||
'img', | ||
'input', | ||
'link', | ||
'meta', | ||
'source', | ||
'track', | ||
'wbr', | ||
]; | ||
// These elements have been deprecated but preserving their usage for backwards compatibility | ||
// until we can officially deprecate them from LWC. | ||
// See: https://html.spec.whatwg.org/multipage/obsolete.html#obsolete-but-conforming-features | ||
const DEPRECATED_VOID_ELEMENTS = ['param', 'keygen', 'menuitem']; | ||
const VOID_ELEMENTS_SET = /*@__PURE__*/ new Set([...VOID_ELEMENTS, ...DEPRECATED_VOID_ELEMENTS]); | ||
/** | ||
* | ||
* @param name | ||
* @param namespace | ||
*/ | ||
function isVoidElement(name, namespace) { | ||
return VOID_ELEMENTS_SET.has(name.toLowerCase()); | ||
} | ||
/** version: 7.2.0 */ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
/** | ||
* This accomplishes two things: | ||
@@ -528,3 +287,3 @@ * | ||
// property name in the component instance. | ||
const reflectedAttrGetters = reflectedPropNames.map((propName) => estreeToolkit.builders.property('get', estreeToolkit.builders.literal(AriaPropNameToAttrNameMap[propName]), estreeToolkit.builders.functionExpression(null, [], estreeToolkit.builders.blockStatement([ | ||
const reflectedAttrGetters = reflectedPropNames.map((propName) => estreeToolkit.builders.property('get', estreeToolkit.builders.literal(shared.AriaPropNameToAttrNameMap[propName]), estreeToolkit.builders.functionExpression(null, [], estreeToolkit.builders.blockStatement([ | ||
estreeToolkit.builders.returnStatement(estreeToolkit.builders.memberExpression(estreeToolkit.builders.identifier('props'), estreeToolkit.builders.identifier(propName))), | ||
@@ -584,3 +343,3 @@ ])))); | ||
Identifier(path, state) { | ||
const reflectedAttrName = AriaPropNameToAttrNameMap[path.node.name]; | ||
const reflectedAttrName = shared.AriaPropNameToAttrNameMap[path.node.name]; | ||
if (reflectedAttrName) { | ||
@@ -738,3 +497,3 @@ state.reflectedPropsInPlay.add(path.node.name); | ||
const imperfectIdentifierMatcher = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/; | ||
const isValidIdentifier = (str) => !reservedKeywords.has(str) && imperfectIdentifierMatcher.test(str); | ||
const isValidIdentifier = (str) => !shared.reservedKeywords.has(str) && imperfectIdentifierMatcher.test(str); | ||
function optimizeAdjacentYieldStmts(statements) { | ||
@@ -922,3 +681,3 @@ let prevStmt = null; | ||
}); | ||
if (isVoidElement(node.name)) { | ||
if (shared.isVoidElement(node.name, shared.HTML_NAMESPACE)) { | ||
return [bYield$1(estreeToolkit.builders.literal(`<${node.name}`)), ...yieldAttrsAndProps, bYield$1(estreeToolkit.builders.literal(`>`))]; | ||
@@ -1207,3 +966,3 @@ } | ||
exports.compileTemplateForSSR = compileTemplateForSSR; | ||
/** version: 7.2.0 */ | ||
/** version: 7.3.0-alpha.2 */ | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -7,2 +7,3 @@ /** | ||
import { parseModule } from 'meriyah'; | ||
import { AriaPropNameToAttrNameMap, reservedKeywords, isVoidElement, HTML_NAMESPACE } from '@lwc/shared'; | ||
import { parse } from 'acorn'; | ||
@@ -13,147 +14,3 @@ import { produce } from 'immer'; | ||
/** | ||
* Copyright (c) 2024 Salesforce, Inc. | ||
*/ | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
/** | ||
* | ||
* @param value | ||
* @param msg | ||
*/ | ||
/* | ||
* Copyright (c) 2024, Salesforce, Inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
const { | ||
/** Detached {@linkcode Object.assign}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign MDN Reference}. */ | ||
assign, | ||
/** Detached {@linkcode Object.create}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create MDN Reference}. */ | ||
create, | ||
/** Detached {@linkcode Object.defineProperties}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties MDN Reference}. */ | ||
defineProperties, | ||
/** Detached {@linkcode Object.defineProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty MDN Reference}. */ | ||
defineProperty, | ||
/** Detached {@linkcode Object.entries}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries MDN Reference}. */ | ||
entries, | ||
/** Detached {@linkcode Object.freeze}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze MDN Reference}. */ | ||
freeze, | ||
/** Detached {@linkcode Object.getOwnPropertyDescriptor}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor MDN Reference}. */ | ||
getOwnPropertyDescriptor, | ||
/** Detached {@linkcode Object.getOwnPropertyDescriptors}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptors MDN Reference}. */ | ||
getOwnPropertyDescriptors, | ||
/** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */ | ||
getOwnPropertyNames, | ||
/** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */ | ||
getPrototypeOf, | ||
/** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */ | ||
hasOwnProperty, | ||
/** Detached {@linkcode Object.isFrozen}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen MDN Reference}. */ | ||
isFrozen, | ||
/** Detached {@linkcode Object.keys}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys MDN Reference}. */ | ||
keys, | ||
/** Detached {@linkcode Object.seal}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal MDN Reference}. */ | ||
seal, | ||
/** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */ | ||
setPrototypeOf, } = Object; | ||
// For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even | ||
// though it works fine for one, e.g. isArray), so comments for these are added to the export | ||
// statement, rather than this declaration. | ||
const { concat: ArrayConcat, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly! | ||
} = Array.prototype; | ||
// No JSDocs here - see comment for Array.prototype | ||
const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype; | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
/** | ||
* According to the following list, there are 48 aria attributes of which two (ariaDropEffect and | ||
* ariaGrabbed) are deprecated: | ||
* https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes | ||
* | ||
* The above list of 46 aria attributes is consistent with the following resources: | ||
* https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060 | ||
* https://wicg.github.io/aom/spec/aria-reflection.html | ||
* | ||
* NOTE: If you update this list, please update test files that implicitly reference this list! | ||
* Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages. | ||
*/ | ||
const AriaPropertyNames = [ | ||
'ariaActiveDescendant', | ||
'ariaAtomic', | ||
'ariaAutoComplete', | ||
'ariaBusy', | ||
'ariaChecked', | ||
'ariaColCount', | ||
'ariaColIndex', | ||
'ariaColIndexText', | ||
'ariaColSpan', | ||
'ariaControls', | ||
'ariaCurrent', | ||
'ariaDescribedBy', | ||
'ariaDescription', | ||
'ariaDetails', | ||
'ariaDisabled', | ||
'ariaErrorMessage', | ||
'ariaExpanded', | ||
'ariaFlowTo', | ||
'ariaHasPopup', | ||
'ariaHidden', | ||
'ariaInvalid', | ||
'ariaKeyShortcuts', | ||
'ariaLabel', | ||
'ariaLabelledBy', | ||
'ariaLevel', | ||
'ariaLive', | ||
'ariaModal', | ||
'ariaMultiLine', | ||
'ariaMultiSelectable', | ||
'ariaOrientation', | ||
'ariaOwns', | ||
'ariaPlaceholder', | ||
'ariaPosInSet', | ||
'ariaPressed', | ||
'ariaReadOnly', | ||
'ariaRelevant', | ||
'ariaRequired', | ||
'ariaRoleDescription', | ||
'ariaRowCount', | ||
'ariaRowIndex', | ||
'ariaRowIndexText', | ||
'ariaRowSpan', | ||
'ariaSelected', | ||
'ariaSetSize', | ||
'ariaSort', | ||
'ariaValueMax', | ||
'ariaValueMin', | ||
'ariaValueNow', | ||
'ariaValueText', | ||
'ariaBrailleLabel', | ||
'ariaBrailleRoleDescription', | ||
'role', | ||
]; | ||
const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (() => { | ||
const AriaAttrNameToPropNameMap = create(null); | ||
const AriaPropNameToAttrNameMap = create(null); | ||
// Synthetic creation of all AOM property descriptors for Custom Elements | ||
forEach.call(AriaPropertyNames, (propName) => { | ||
const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-')); | ||
AriaAttrNameToPropNameMap[attrName] = propName; | ||
AriaPropNameToAttrNameMap[propName] = attrName; | ||
}); | ||
return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap }; | ||
})(); | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
@@ -164,101 +21,3 @@ * All rights reserved. | ||
*/ | ||
const reservedKeywords = new Set([ | ||
'NaN', | ||
'arguments', | ||
'break', | ||
'case', | ||
'catch', | ||
'class', | ||
'const', | ||
'continue', | ||
'debugger', | ||
'default', | ||
'delete', | ||
'do', | ||
'else', | ||
'enum', | ||
'eval', | ||
'export', | ||
'extends', | ||
'false', | ||
'finally', | ||
'for', | ||
'function', | ||
'if', | ||
'implements', | ||
'import', | ||
'in', | ||
'instanceof', | ||
'interface', | ||
'let', | ||
'new', | ||
'null', | ||
'package', | ||
'private', | ||
'protected', | ||
'public', | ||
'return', | ||
'static', | ||
'super', | ||
'switch', | ||
'this', | ||
'throw', | ||
'true', | ||
'try', | ||
'typeof', | ||
'undefined', | ||
'var', | ||
'void', | ||
'while', | ||
'with', | ||
'yield', | ||
]); | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
// Void elements are elements that self-close even without an explicit solidus (slash), | ||
// e.g. `</tagName>` or `<tagName />`. For instance, `<meta>` closes on its own; no need for a slash. | ||
// These only come from HTML; there are no void elements in the SVG or MathML namespaces. | ||
// See: https://html.spec.whatwg.org/multipage/syntax.html#syntax-tags | ||
const VOID_ELEMENTS = [ | ||
'area', | ||
'base', | ||
'br', | ||
'col', | ||
'embed', | ||
'hr', | ||
'img', | ||
'input', | ||
'link', | ||
'meta', | ||
'source', | ||
'track', | ||
'wbr', | ||
]; | ||
// These elements have been deprecated but preserving their usage for backwards compatibility | ||
// until we can officially deprecate them from LWC. | ||
// See: https://html.spec.whatwg.org/multipage/obsolete.html#obsolete-but-conforming-features | ||
const DEPRECATED_VOID_ELEMENTS = ['param', 'keygen', 'menuitem']; | ||
const VOID_ELEMENTS_SET = /*@__PURE__*/ new Set([...VOID_ELEMENTS, ...DEPRECATED_VOID_ELEMENTS]); | ||
/** | ||
* | ||
* @param name | ||
* @param namespace | ||
*/ | ||
function isVoidElement(name, namespace) { | ||
return VOID_ELEMENTS_SET.has(name.toLowerCase()); | ||
} | ||
/** version: 7.2.0 */ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
/** | ||
* This accomplishes two things: | ||
@@ -915,3 +674,3 @@ * | ||
}); | ||
if (isVoidElement(node.name)) { | ||
if (isVoidElement(node.name, HTML_NAMESPACE)) { | ||
return [bYield$1(builders.literal(`<${node.name}`)), ...yieldAttrsAndProps, bYield$1(builders.literal(`>`))]; | ||
@@ -1199,3 +958,3 @@ } | ||
export { compileComponentForSSR, compileTemplateForSSR }; | ||
/** version: 7.2.0 */ | ||
/** version: 7.3.0-alpha.2 */ | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ { | ||
"name": "@lwc/ssr-compiler", | ||
"version": "7.3.0-alpha.1", | ||
"version": "7.3.0-alpha.2", | ||
"description": "Compile component for use during server-side rendering", | ||
@@ -48,8 +48,9 @@ "keywords": [ | ||
"dependencies": { | ||
"@lwc/template-compiler": "7.3.0-alpha.1", | ||
"@lwc/shared": "7.3.0-alpha.2", | ||
"@lwc/template-compiler": "7.3.0-alpha.2", | ||
"acorn": "8.12.1", | ||
"astring": "^1.8.6", | ||
"estree-toolkit": "^1.7.5", | ||
"estree-toolkit": "^1.7.6", | ||
"immer": "^10.1.1", | ||
"meriyah": "^4.5.0" | ||
"meriyah": "^5.0.0" | ||
}, | ||
@@ -56,0 +57,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
156798
-34.74%7
16.67%2051
-18.74%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated
Updated