@lwc/engine-core 8.1.2 → 8.2.0

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.
@@ -20,7 +20,7 @@ export { getComponentConstructor } from './get-component-constructor';
20
20
  export type { RendererAPI, LifecycleCallback } from './renderer';
21
21
  export type { Stylesheets } from './stylesheet';
22
22
  export type { Template } from './template';
23
- export type { ConfigValue as WireConfigValue, ContextConsumer as WireContextConsumer, ContextProvider as WireContextProvider, ContextValue as WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './wiring';
23
+ export type { ConfigValue as WireConfigValue, ContextConsumer as WireContextConsumer, ContextProvider as WireContextProvider, ContextValue as WireContextValue, DataCallback as WireDataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, WireContextSubscriptionPayload, WireContextSubscriptionCallback, } from './wiring';
24
24
  export type { FormRestoreState, FormRestoreReason } from './vm';
25
25
  export { LightningElement } from './base-lightning-element';
26
26
  export { default as api } from './decorators/api';
@@ -6,9 +6,6 @@ export declare const EmptyObject: any;
6
6
  export declare const EmptyArray: never[];
7
7
  export declare function addCallbackToNextTick(callback: Callback): void;
8
8
  export declare function guid(): string;
9
- export declare function parseStyleText(cssText: string): {
10
- [name: string]: string;
11
- };
12
9
  export declare function cloneAndOmitKey(object: {
13
10
  [key: string]: any;
14
11
  }, keyToOmit: string): {
package/dist/index.cjs.js CHANGED
@@ -221,23 +221,6 @@ function guid() {
221
221
  }
222
222
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
223
223
  }
224
- // Borrowed from Vue template compiler.
225
- // https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
226
- const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
227
- const PROPERTY_DELIMITER = /:(.+)/;
228
- function parseStyleText(cssText) {
229
- const styleMap = {};
230
- const declarations = cssText.split(DECLARATION_DELIMITER);
231
- for (const declaration of declarations) {
232
- if (declaration) {
233
- const [prop, value] = declaration.split(PROPERTY_DELIMITER);
234
- if (prop !== undefined && value !== undefined) {
235
- styleMap[prop.trim()] = value.trim();
236
- }
237
- }
238
- }
239
- return styleMap;
240
- }
241
224
  // Make a shallow copy of an object but omit the given key
242
225
  function cloneAndOmitKey(object, keyToOmit) {
243
226
  const result = {};
@@ -3937,6 +3920,12 @@ function isVStaticPartText(vnode) {
3937
3920
  return vnode.type === 0 /* VStaticPartType.Text */;
3938
3921
  }
3939
3922
 
3923
+ /*
3924
+ * Copyright (c) 2024, Salesforce, Inc.
3925
+ * All rights reserved.
3926
+ * SPDX-License-Identifier: MIT
3927
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3928
+ */
3940
3929
  const sanitizedHtmlContentSymbol = Symbol('lwc-get-sanitized-html-content');
3941
3930
  function isSanitizedHtmlContent(object) {
3942
3931
  return shared.isObject(object) && !shared.isNull(object) && sanitizedHtmlContentSymbol in object;
@@ -7658,31 +7647,41 @@ function textNodeContentsAreEqual(node, vnode, renderer) {
7658
7647
  // Any attribute names specified in that array will not be validated, and the
7659
7648
  // LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
7660
7649
  function getValidationPredicate(elm, renderer, optOutStaticProp) {
7661
- // `data-lwc-host-mutated` is a special attribute added by the SSR engine itself,
7662
- // which does the same thing as an explicit `static validationOptOut = ['attr1', 'attr2']`.
7650
+ // `data-lwc-host-mutated` is a special attribute added by the SSR engine itself, which automatically detects
7651
+ // host mutations during `connectedCallback`.
7663
7652
  const hostMutatedValue = renderer.getAttribute(elm, 'data-lwc-host-mutated');
7664
- if (shared.isString(hostMutatedValue)) {
7665
- const mutatedAttrValues = new Set(shared.StringSplit.call(hostMutatedValue, / /));
7666
- return (attrName) => !mutatedAttrValues.has(attrName);
7667
- }
7668
- if (shared.isUndefined(optOutStaticProp)) {
7669
- return (_attrName) => true;
7670
- }
7653
+ const detectedHostMutations = shared.isString(hostMutatedValue)
7654
+ ? new Set(shared.StringSplit.call(hostMutatedValue, / /))
7655
+ : undefined;
7671
7656
  // If validationOptOut is true, no attributes will be checked for correctness
7672
7657
  // and the runtime will assume VDOM attrs and DOM attrs are in sync.
7673
- if (shared.isTrue(optOutStaticProp)) {
7674
- return (_attrName) => false;
7675
- }
7676
- // If validationOptOut is an array of strings, attributes specified in the
7677
- // array will be "opted out". Attributes not specified in the array will still
7678
- // be validated.
7679
- if (shared.isArray(optOutStaticProp) && shared.arrayEvery(optOutStaticProp, shared.isString)) {
7680
- return (attrName) => !shared.ArrayIncludes.call(optOutStaticProp, attrName);
7681
- }
7682
- if (process.env.NODE_ENV !== 'production') {
7683
- logWarn('Validation opt out must be `true` or an array of attributes that should not be validated.');
7684
- }
7685
- return (_attrName) => true;
7658
+ const fullOptOut = shared.isTrue(optOutStaticProp);
7659
+ // If validationOptOut is an array of strings, attributes specified in the array will be "opted out". Attributes
7660
+ // not specified in the array will still be validated.
7661
+ const isValidArray = shared.isArray(optOutStaticProp) && shared.arrayEvery(optOutStaticProp, shared.isString);
7662
+ const conditionalOptOut = isValidArray ? new Set(optOutStaticProp) : undefined;
7663
+ if (process.env.NODE_ENV !== 'production' &&
7664
+ !shared.isUndefined(optOutStaticProp) &&
7665
+ !shared.isTrue(optOutStaticProp) &&
7666
+ !isValidArray) {
7667
+ logWarn('`validationOptOut` must be `true` or an array of attributes that should not be validated.');
7668
+ }
7669
+ return (attrName) => {
7670
+ // Component wants to opt out of all validation
7671
+ if (fullOptOut) {
7672
+ return false;
7673
+ }
7674
+ // Mutations were automatically detected and should be ignored
7675
+ if (!shared.isUndefined(detectedHostMutations) && detectedHostMutations.has(attrName)) {
7676
+ return false;
7677
+ }
7678
+ // Component explicitly wants to opt out of certain validations, regardless of auto-detection
7679
+ if (!shared.isUndefined(conditionalOptOut) && conditionalOptOut.has(attrName)) {
7680
+ return false;
7681
+ }
7682
+ // Attribute must be validated
7683
+ return true;
7684
+ };
7686
7685
  }
7687
7686
  function hydrateText(node, vnode, renderer) {
7688
7687
  if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
@@ -8046,12 +8045,12 @@ function validateStyleAttr(vnode, elm, data, renderer) {
8046
8045
  vnodeStyle = style;
8047
8046
  }
8048
8047
  else if (!shared.isUndefined(styleDecls)) {
8049
- const parsedVnodeStyle = parseStyleText(elmStyle);
8048
+ const parsedVnodeStyle = shared.parseStyleText(elmStyle);
8050
8049
  const expectedStyle = [];
8051
8050
  // styleMap is used when style is set to static value.
8052
8051
  for (let i = 0, n = styleDecls.length; i < n; i++) {
8053
8052
  const [prop, value, important] = styleDecls[i];
8054
- expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
8053
+ expectedStyle.push(`${prop}: ${value + (important ? ' !important' : '')};`);
8055
8054
  const parsedPropValue = parsedVnodeStyle[prop];
8056
8055
  if (shared.isUndefined(parsedPropValue)) {
8057
8056
  nodesAreCompatible = false;
@@ -8066,7 +8065,7 @@ function validateStyleAttr(vnode, elm, data, renderer) {
8066
8065
  if (shared.keys(parsedVnodeStyle).length > styleDecls.length) {
8067
8066
  nodesAreCompatible = false;
8068
8067
  }
8069
- vnodeStyle = shared.ArrayJoin.call(expectedStyle, ';');
8068
+ vnodeStyle = shared.ArrayJoin.call(expectedStyle, ' ');
8070
8069
  }
8071
8070
  if (!nodesAreCompatible) {
8072
8071
  if (process.env.NODE_ENV !== 'production') {
@@ -8478,5 +8477,5 @@ exports.swapTemplate = swapTemplate;
8478
8477
  exports.track = track;
8479
8478
  exports.unwrap = unwrap;
8480
8479
  exports.wire = wire;
8481
- /** version: 8.1.2 */
8480
+ /** version: 8.2.0 */
8482
8481
  //# sourceMappingURL=index.cjs.js.map