@lwc/engine-core 6.6.0 → 6.6.2

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/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Copyright (c) 2024 Salesforce, Inc.
3
3
  */
4
- import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArrayPop, create, isFalse, isFunction as isFunction$1, isObject, seal, isAPIFeatureEnabled, isArray as isArray$1, keys, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, freeze, KEY__SYNTHETIC_MODE, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, ArraySplice, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, ArrayShift, ArrayUnshift, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, htmlEscape, StringCharAt, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse } from '@lwc/shared';
4
+ import { noop, StringToLowerCase, isNull, ArrayPush as ArrayPush$1, ArrayJoin, isFrozen, isUndefined as isUndefined$1, defineProperty, ArrayIndexOf, ArrayPop, create, isFalse, isFunction as isFunction$1, isObject, seal, isAPIFeatureEnabled, isArray as isArray$1, keys, hasOwnProperty as hasOwnProperty$1, entries, AriaPropNameToAttrNameMap, getPropertyDescriptor, forEach, defineProperties, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, assign, freeze, KEY__SYNTHETIC_MODE, assert, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, getOwnPropertyNames as getOwnPropertyNames$1, getOwnPropertyDescriptors, htmlPropertyToAttribute, ArraySlice, ArrayMap, KEY__SCOPED_CSS, ArraySplice, kebabCaseToCamelCase, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, isTrue, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, ArraySome, isNumber, StringReplace, htmlEscape, StringCharAt, ArrayUnshift, LOWEST_API_VERSION, KEY__NATIVE_GET_ELEMENT_BY_ID, KEY__NATIVE_QUERY_SELECTOR_ALL, ID_REFERENCING_ATTRIBUTES_SET, KEY__SHADOW_TOKEN, ArrayFilter, StringSplit, arrayEvery, ArrayIncludes, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift } from '@lwc/shared';
5
5
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
6
6
 
7
7
  /*
@@ -4071,7 +4071,7 @@ function updateTextContent$1(vnode, renderer) {
4071
4071
  }
4072
4072
 
4073
4073
  /*
4074
- * Copyright (c) 2023, salesforce.com, inc.
4074
+ * Copyright (c) 2024, Salesforce, Inc.
4075
4075
  * All rights reserved.
4076
4076
  * SPDX-License-Identifier: MIT
4077
4077
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
@@ -4097,31 +4097,56 @@ function traverseAndSetElements(root, parts, renderer) {
4097
4097
  for (const staticPart of parts) {
4098
4098
  partIdsToParts.set(staticPart.partId, staticPart);
4099
4099
  }
4100
+ // Note that we traverse using `*Child`/`*Sibling` rather than `children` because the browser uses a linked
4101
+ // list under the hood to represent the DOM tree, so it's faster to do this than to create an underlying array
4102
+ // by calling `children`.
4103
+ const { nextSibling, getFirstChild, getParentNode } = renderer;
4100
4104
  let numFoundParts = 0;
4101
- const { previousSibling, getLastChild } = renderer;
4102
- const stack = [root];
4103
4105
  let partId = -1;
4106
+ // We should never traverse up to the root. We should exit early due to numFoundParts === numParts.
4107
+ // This is just a sanity check, in case the static parts generated by @lwc/template-compiler are wrong.
4108
+ function assertNotRoot(node) {
4109
+ if (process.env.NODE_ENV !== 'production') {
4110
+ assert.isFalse(node === root, `Reached the root without finding all parts. Found ${numFoundParts}, needed ${numParts}.`);
4111
+ }
4112
+ }
4104
4113
  // Depth-first traversal. We assign a partId to each element, which is an integer based on traversal order.
4105
- while (stack.length > 0) {
4106
- const elm = ArrayShift.call(stack);
4114
+ // This function is very hot, which is why it's micro-optimized. Note we don't use a stack at all; we traverse
4115
+ // using an algorithm that relies on the parentNode getter: https://stackoverflow.com/a/5285417
4116
+ // This is very slightly faster than a TreeWalker (~0.5% on js-framework-benchmark create-10k), but basically
4117
+ // the same idea.
4118
+ let node = root;
4119
+ while (!isNull(node)) {
4120
+ // visit node
4107
4121
  partId++;
4108
4122
  const part = partIdsToParts.get(partId);
4109
4123
  if (!isUndefined$1(part)) {
4110
- part.elm = elm;
4111
- if (++numFoundParts === numParts) {
4124
+ part.elm = node;
4125
+ numFoundParts++;
4126
+ if (numFoundParts === numParts) {
4112
4127
  return; // perf optimization - stop traversing once we've found everything we need
4113
4128
  }
4114
4129
  }
4115
- // For depth-first traversal, prepend to the stack in reverse order
4116
- // Note that we traverse using `*Child`/`*Sibling` rather than `children` because the browser uses a linked
4117
- // list under the hood to represent the DOM tree, so it's faster to do this than to create an underlying array
4118
- // by calling `children`.
4119
- let child = getLastChild(elm);
4120
- while (!isNull(child)) {
4121
- ArrayUnshift.call(stack, child);
4122
- child = previousSibling(child);
4130
+ const child = getFirstChild(node);
4131
+ if (!isNull(child)) {
4132
+ // walk down
4133
+ node = child;
4134
+ }
4135
+ else {
4136
+ let sibling;
4137
+ while (isNull((sibling = nextSibling(node)))) {
4138
+ // we never want to walk up from the root
4139
+ assertNotRoot(node);
4140
+ // walk up
4141
+ node = getParentNode(node);
4142
+ }
4143
+ // we never want to walk right from the root
4144
+ assertNotRoot(node);
4145
+ // walk right
4146
+ node = sibling;
4123
4147
  }
4124
4148
  }
4149
+ /* istanbul ignore next */
4125
4150
  if (process.env.NODE_ENV !== 'production') {
4126
4151
  assert.isTrue(numFoundParts === numParts, `Should have found all parts by now. Found ${numFoundParts}, needed ${numParts}.`);
4127
4152
  }
@@ -7893,5 +7918,5 @@ function readonly(obj) {
7893
7918
  }
7894
7919
 
7895
7920
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, setHooks, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
7896
- /** version: 6.6.0 */
7921
+ /** version: 6.6.2 */
7897
7922
  //# sourceMappingURL=index.js.map