Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v6.0.0 #3947

Merged
merged 7 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/karma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ jobs:
- run: DISABLE_SYNTHETIC=1 yarn sauce:ci
- run: LEGACY_BROWSERS=1 yarn sauce:ci
- run: FORCE_NATIVE_SHADOW_MODE_FOR_TEST=1 yarn sauce:ci
- run: ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE=1 yarn sauce:ci
- run: ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE=1 DISABLE_SYNTHETIC=1 yarn sauce:ci
- run: API_VERSION=58 yarn sauce:ci
- run: API_VERSION=58 DISABLE_SYNTHETIC=1 yarn sauce:ci
- run: API_VERSION=59 yarn sauce:ci
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,15 @@ jobs:
run: yarn bundlesize
- name: Run Jest tests
run: yarn test:ci
- name: Upload Jest coverage report
uses: actions/upload-artifact@v3
with:
name: jest-coverage-report
path: coverage/
- name: Run benchmark smoke tests
run: CHROME_BINARY=${{ steps.setup-chrome.outputs.chrome-path }} BENCHMARK_SMOKE_TEST=1 yarn test:performance
- name: Add step summary
# 1. Remove leading/trailing "border" lines from output
# 2. Wrap file names in backticks
# 3. Convert leading whitespace to non-breaking to approximate plaintext output
run: sed -E '$d;1d;4,$s/^( ?)([^ ]+)/\1`\2`/g;4,$s/^ /\ \ /g' coverage/coverage.txt >> "$GITHUB_STEP_SUMMARY"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lwc-monorepo",
"version": "5.3.0",
"version": "6.0.0",
"private": true,
"description": "Lightning Web Components",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/aria-reflection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/aria-reflection",
"version": "5.3.0",
"version": "6.0.0",
"description": "ARIA element reflection polyfill for strings",
"keywords": [
"aom",
Expand Down
6 changes: 3 additions & 3 deletions packages/@lwc/babel-plugin-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/babel-plugin-component",
"version": "5.3.0",
"version": "6.0.0",
"description": "Babel plugin to transform a LWC module",
"keywords": [
"lwc"
Expand Down Expand Up @@ -43,8 +43,8 @@
},
"dependencies": {
"@babel/helper-module-imports": "7.22.15",
"@lwc/errors": "5.3.0",
"@lwc/shared": "5.3.0",
"@lwc/errors": "6.0.0",
"@lwc/shared": "6.0.0",
"line-column": "~1.0.2"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions packages/@lwc/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/compiler",
"version": "5.3.0",
"version": "6.0.0",
"description": "LWC compiler",
"keywords": [
"lwc"
Expand Down Expand Up @@ -48,10 +48,10 @@
"@babel/plugin-proposal-object-rest-spread": "7.20.7",
"@babel/plugin-transform-async-to-generator": "7.23.3",
"@locker/babel-plugin-transform-unforgeables": "0.20.0",
"@lwc/babel-plugin-component": "5.3.0",
"@lwc/errors": "5.3.0",
"@lwc/shared": "5.3.0",
"@lwc/style-compiler": "5.3.0",
"@lwc/template-compiler": "5.3.0"
"@lwc/babel-plugin-component": "6.0.0",
"@lwc/errors": "6.0.0",
"@lwc/shared": "6.0.0",
"@lwc/style-compiler": "6.0.0",
"@lwc/template-compiler": "6.0.0"
}
}
6 changes: 3 additions & 3 deletions packages/@lwc/engine-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
],
"name": "@lwc/engine-core",
"version": "5.3.0",
"version": "6.0.0",
"description": "Core LWC engine APIs.",
"keywords": [
"lwc"
Expand Down Expand Up @@ -42,8 +42,8 @@
}
},
"dependencies": {
"@lwc/features": "5.3.0",
"@lwc/shared": "5.3.0"
"@lwc/features": "6.0.0",
"@lwc/shared": "6.0.0"
},
"devDependencies": {
"observable-membrane": "2.0.0"
Expand Down
37 changes: 30 additions & 7 deletions packages/@lwc/engine-core/src/framework/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import {
VText,
VStaticPart,
VStaticPartData,
isVBaseElement,
isVStatic,
} from './vnodes';
import { getComponentRegisteredName } from './component';

Expand Down Expand Up @@ -92,6 +94,7 @@ function st(fragment: Element, key: Key, parts?: VStaticPart[]): VStatic {
fragment,
owner,
parts,
slotAssignment: undefined,
};

return vnode;
Expand Down Expand Up @@ -160,7 +163,7 @@ function h(sel: string, data: VElementData, children: VNodes = EmptyArray): VEle
});
}

const { key } = data;
const { key, slotAssignment } = data;

const vnode: VElement = {
type: VNodeType.Element,
Expand All @@ -170,6 +173,7 @@ function h(sel: string, data: VElementData, children: VNodes = EmptyArray): VEle
elm: undefined,
key,
owner: vmBeingRendered,
slotAssignment,
};

return vnode;
Expand Down Expand Up @@ -207,6 +211,10 @@ function s(
assert.isTrue(isObject(data), `s() 2nd argument data must be an object.`);
assert.isTrue(isArray(children), `h() 3rd argument children must be an array.`);
}

const vmBeingRendered = getVMBeingRendered()!;
const { renderMode, apiVersion } = vmBeingRendered;

if (
!isUndefined(slotset) &&
!isUndefined(slotset.slotAssignments) &&
Expand Down Expand Up @@ -236,7 +244,6 @@ function s(
}
// If the passed slot content is factory, evaluate it and add the produced vnodes
if (assignedNodeIsScopedSlot) {
const vmBeingRenderedInception = getVMBeingRendered();
// Evaluate in the scope of the slot content's owner
// if a slotset is provided, there will always be an owner. The only case where owner is
// undefined is for root components, but root components cannot accept slotted content
Expand All @@ -249,19 +256,34 @@ function s(
ArrayPush.call(newChildren, vnode.factory(data.slotData, data.key));
});
} finally {
setVMBeingRendered(vmBeingRenderedInception);
setVMBeingRendered(vmBeingRendered);
}
} else {
// This block is for standard slots (non-scoped slots)
let clonedVNode;
if (
renderMode === RenderMode.Light &&
isAPIFeatureEnabled(APIFeature.USE_LIGHT_DOM_SLOT_FORWARDING, apiVersion) &&
(isVBaseElement(vnode) || isVStatic(vnode)) &&
// We only need to copy the vnodes when the slot assignment changes, copying every time causes issues with
// disconnected/connected callback firing.
vnode.slotAssignment !== data.slotAssignment
) {
// When the light DOM slot assignment (slot attribute) changes we can't use the same reference
// to the vnode because the current way the diffing algo works, it will replace the original reference
// to the host element with a new one. This means the new element will be mounted and immediately unmounted.
// Creating a copy of the vnode to preserve a reference to the previous host element.
clonedVNode = { ...vnode, slotAssignment: data.slotAssignment };
}
// If the slot content is standard type, the content is static, no additional
// processing needed on the vnode
ArrayPush.call(newChildren, vnode);
ArrayPush.call(newChildren, clonedVNode ?? vnode);
}
}
}
children = newChildren;
}
const vmBeingRendered = getVMBeingRendered()!;
const { renderMode, shadowMode, apiVersion } = vmBeingRendered;
const { shadowMode } = vmBeingRendered;

if (renderMode === RenderMode.Light) {
// light DOM slots - backwards-compatible behavior uses flattening, new behavior uses fragments
Expand Down Expand Up @@ -324,7 +346,7 @@ function c(
});
}
}
const { key } = data;
const { key, slotAssignment } = data;
let elm, aChildren, vm;
const vnode: VCustomElement = {
type: VNodeType.CustomElement,
Expand All @@ -333,6 +355,7 @@ function c(
children,
elm,
key,
slotAssignment,

ctor: Ctor,
owner: vmBeingRendered,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import {
import { componentValueObserved } from './mutation-tracker';
import {
patchCustomElementWithRestrictions,
patchLightningElementPrototypeWithRestrictions,
patchShadowRootWithRestrictions,
} from './restrictions';
import { getVMBeingRendered, isUpdatingTemplate, Template } from './template';
Expand Down Expand Up @@ -851,7 +850,3 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
},
configurable: true,
});

if (process.env.NODE_ENV !== 'production') {
patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
}
23 changes: 22 additions & 1 deletion packages/@lwc/engine-core/src/framework/modules/attrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { RendererAPI } from '../renderer';

import { EmptyObject } from '../utils';
import { VBaseElement } from '../vnodes';
import { VBaseElement, VStatic } from '../vnodes';

const ColonCharCode = 58;

Expand Down Expand Up @@ -63,3 +63,24 @@ export function patchAttributes(
}
}
}

export function patchSlotAssignment(
oldVnode: VBaseElement | VStatic | null,
vnode: VBaseElement | VStatic,
renderer: RendererAPI
) {
const { slotAssignment } = vnode;

if (oldVnode?.slotAssignment === slotAssignment) {
return;
}

const { elm } = vnode;
const { setAttribute, removeAttribute } = renderer;

if (isUndefined(slotAssignment) || isNull(slotAssignment)) {
removeAttribute(elm, 'slot');
} else {
setAttribute(elm, 'slot', slotAssignment);
}
}
6 changes: 5 additions & 1 deletion packages/@lwc/engine-core/src/framework/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export interface RendererAPI {
isConnected: (node: N) => boolean;
insertStylesheet: (content: string, target?: ShadowRoot) => void;
assertInstanceOfHTMLElement: (elm: any, msg: string) => void;
createCustomElement: (tagName: string, upgradeCallback: LifecycleCallback) => E;
createCustomElement: (
tagName: string,
upgradeCallback: LifecycleCallback,
useNativeLifecycle: boolean
) => E;
defineCustomElement: (tagName: string) => void;
ownerDocument(elm: E): Document;
registerContextConsumer: (
Expand Down
24 changes: 17 additions & 7 deletions packages/@lwc/engine-core/src/framework/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { logError } from '../shared/logger';
import { getComponentTag } from '../shared/format';
import { RendererAPI } from './renderer';
import { EmptyArray } from './utils';
import { EmptyArray, shouldUseNativeCustomElementLifecycle } from './utils';
import { markComponentAsDirty } from './component';
import { getScopeTokenClass } from './stylesheet';
import { lockDomMutation, patchElementWithRestrictions, unlockDomMutation } from './restrictions';
Expand All @@ -47,6 +47,7 @@ import {
isVCustomElement,
isVFragment,
isVScopedSlotFragment,
isVStatic,
Key,
VBaseElement,
VComment,
Expand All @@ -60,7 +61,7 @@ import {
VText,
} from './vnodes';

import { patchAttributes } from './modules/attrs';
import { patchAttributes, patchSlotAssignment } from './modules/attrs';
import { patchProps } from './modules/props';
import { patchClassAttribute } from './modules/computed-class-attr';
import { patchStyleAttribute } from './modules/computed-style-attr';
Expand All @@ -69,6 +70,7 @@ import { applyStaticClassAttribute } from './modules/static-class-attr';
import { applyStaticStyleAttribute } from './modules/static-style-attr';
import { applyRefs } from './modules/refs';
import { applyStaticParts } from './modules/static-parts';
import { LightningElementConstructor } from './base-lightning-element';

export function patchChildren(
c1: VNodes,
Expand Down Expand Up @@ -265,6 +267,8 @@ function mountElement(
function patchStatic(n1: VStatic, n2: VStatic, renderer: RendererAPI) {
const elm = (n2.elm = n1.elm!);

// slotAssignments can only apply to the top level element, never to a static part.
patchSlotAssignment(n1, n2, renderer);
// The `refs` object is blown away in every re-render, so we always need to re-apply them
applyStaticParts(elm, n2, renderer, false);
}
Expand Down Expand Up @@ -298,6 +302,8 @@ function mountStatic(
}
}

// slotAssignments can only apply to the top level element, never to a static part.
patchSlotAssignment(null, vnode, renderer);
insertNode(elm, parent, anchor, renderer);
applyStaticParts(elm, vnode, renderer, true);
}
Expand All @@ -308,7 +314,7 @@ function mountCustomElement(
anchor: Node | null,
renderer: RendererAPI
) {
const { sel, owner } = vnode;
const { sel, owner, ctor } = vnode;
const { createCustomElement } = renderer;
/**
* Note: if the upgradable constructor does not expect, or throw when we new it
Expand All @@ -328,7 +334,10 @@ function mountCustomElement(
// compiler may generate tagnames with uppercase letters so - for backwards
// compatibility, we lower case the tagname here.
const normalizedTagname = sel.toLowerCase();
const elm = createCustomElement(normalizedTagname, upgradeCallback);
const useNativeLifecycle = shouldUseNativeCustomElementLifecycle(
ctor as LightningElementConstructor
);
const elm = createCustomElement(normalizedTagname, upgradeCallback, useNativeLifecycle);

vnode.elm = elm;
vnode.vm = vm;
Expand All @@ -345,7 +354,7 @@ function mountCustomElement(

if (vm) {
if (process.env.IS_BROWSER) {
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
if (!useNativeLifecycle) {
if (process.env.NODE_ENV !== 'production') {
// With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
// noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
Expand Down Expand Up @@ -597,6 +606,7 @@ function patchElementPropsAndAttrsAndRefs(

patchAttributes(oldVnode, vnode, renderer);
patchProps(oldVnode, vnode, renderer);
patchSlotAssignment(oldVnode, vnode, renderer);

// The `refs` object is blown away in every re-render, so we always need to re-apply them
applyRefs(vnode, vnode.owner);
Expand Down Expand Up @@ -795,8 +805,8 @@ function allocateInSlot(vm: VM, children: VNodes, owner: VM) {
}

let slotName: unknown = '';
if (isVBaseElement(vnode)) {
slotName = vnode.data.attrs?.slot ?? '';
if (isVBaseElement(vnode) || isVStatic(vnode)) {
slotName = vnode.slotAssignment ?? '';
} else if (isVScopedSlotFragment(vnode)) {
slotName = vnode.slotName;
}
Expand Down
Loading