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

refactor: use fragments for slots in light DOM (BREAKING CHANGE) #3649

Merged
merged 9 commits into from
Oct 20, 2023

Conversation

nolanlawson
Copy link
Collaborator

Details

Same as #3308, but uses API versioning. This is still a breaking change (for off-core consumers).

Does this pull request introduce a breaking change?

  • 🚨 Yes, it does introduce a breaking change.

Off-core consumers, or those bumping their component's metadata apiVersion to 60+, will see additional empty text nodes rendered in light DOM slots. This can change use cases like the following:

renderedCallback() {
  const myExpectedChildNode = this.childNodes[0];
}

In API versions <60, the above this.childNodes[0] would resolve to the first slotted element in the light DOM component.

In API versions >=60, it will be an empty text node. This is due to the new system using VFragments to enclose light DOM slots, which means there is an additional empty text node before and after the slot.

Affected APIs are:

  • childNodes
  • firstChildNode
  • lastChildNode

Component authors are encouraged to use lwc:ref or this.querySelector rather than relying on the exact makeup of child nodes. Using children/firstChild/lastChild will also work, since text nodes are not elements (simply nodes).

Additionally, Jest snapshots will change to have additional whitespace, unless you have upgraded to lwc-test v13.0.0+.

Does this pull request introduce an observable change?

  • ⚠️ Yes, it does include an observable change.

See above.

GUS work item

W-13818735

@nolanlawson nolanlawson requested a review from a team as a code owner August 3, 2023 17:33
@nolanlawson nolanlawson changed the base branch from master to release-v4.0.0 August 3, 2023 17:33
@nolanlawson

This comment was marked as outdated.

@nolanlawson nolanlawson modified the milestones: 3.0.0, 4.0.0 Aug 3, 2023
@nolanlawson

This comment was marked as outdated.

@nolanlawson nolanlawson changed the base branch from release-v4.0.0 to prerelease-v4.0.0 August 8, 2023 22:31
@nolanlawson

This comment was marked as outdated.

@nolanlawson
Copy link
Collaborator Author

We're breaking downstreams, need salesforce/lwc-test#205 to be released first

@nolanlawson nolanlawson changed the base branch from prerelease-v4.0.0 to milestone-v4.0.0 August 10, 2023 16:40
@nolanlawson nolanlawson changed the base branch from milestone-v4.0.0 to master August 10, 2023 19:09
@nolanlawson
Copy link
Collaborator Author

/nucleus test

1 similar comment
@nolanlawson
Copy link
Collaborator Author

/nucleus test

@nolanlawson
Copy link
Collaborator Author

/nucleus ignore --reason 'downstream webruntime test has SSR snapshot with duplicate style that apparently this PR fixes'

@nolanlawson nolanlawson merged commit dcb37c9 into master Oct 20, 2023
11 checks passed
@nolanlawson nolanlawson deleted the nolan/fragments-slots-light-dom branch October 20, 2023 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants