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

fix(synthetic-shadow): Fix API interaction with light DOM components #2393

Merged
merged 9 commits into from Jul 29, 2021

Conversation

pmdartus
Copy link
Member

Details

This PR fixes incorrect behavior when light DOM components are used with synthetic shadow DOM:

  • HTMLSlotElement.prototype.assignedNodes and HTMLSlotElement.prototype.assignedElements on shadow slots and light DOM slotted content.
  • Node.prototype.parentNode and Node.prototype.parentElenent on light DOM slotted content inside a shadow DOM component.

Fix #2386

Does this PR introduce breaking changes?

  • No, it does not introduce breaking changes.

The PR fulfills these requirements:

  • Have tests for the proposed changes been added? ✅
  • Have you followed these instructions to clearly describe the issue being fixed or feature enhanced? ✅

@pmdartus pmdartus marked this pull request as ready for review July 7, 2021 15:31
expect(nodes.p.parentElement).toEqual(nodes.consumer);
});
xit('getRootNode', () => {
expect(nodes.p.getRootNode()).toEqual(document);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember we had a discussion about owner keys during a dev sync but I don't remember the details. Did we say that Light DOM components should inherit owner keys? I guess we could get this working if we did?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little more complex than this. Node.prototype.getRootNode fails when a light DOM element is the top-level light DOM element because there is no owner key to inherit from.

);
});
xit('innerHTML', () => {
expect(nodes.consumer.innerHTML).toEqual(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns an empty string with synthetic shadow--is that because the slotted content has no associated owner key?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right.

@pmdartus
Copy link
Member Author

@ekashida I am not planning to fix the new bugs I uncovered as part of this PR, I created dedicated issues for each bug.
Could you review the slotting changes I made?

Copy link
Contributor

@jodarove jodarove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. just a note: This change may have perf implications. IIRC, in the platform, .parentNode is part of the critical path because Aura uses it to render aura components. and isSlotElement does node instanceof HTMLSlotElement.

@jodarove jodarove self-requested a review July 28, 2021 23:23
Copy link
Contributor

@jodarove jodarove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(dismiss my previous request for change) This does LGTM. Just a note: This change may have perf implications in the platform. IIRC, in the platform, .parentNode is part of the critical path because Aura uses it to render aura components. and isSlotElement does node instanceof HTMLSlotElement.

Copy link
Member

@ekashida ekashida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jodarove jodarove merged commit 97c3714 into master Jul 29, 2021
@jodarove jodarove deleted the pmdartus/light-dom-assigned-elements branch July 29, 2021 01:23
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.

Slot assignedElements and assignedNodes returns incorrect value with light DOM and synthetic shadow
4 participants