-
Notifications
You must be signed in to change notification settings - Fork 776
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
feat(duplicate-id): Add shadow DOM support #452
Conversation
|
||
assert.isFalse(checks['duplicate-id'].evaluate.call(checkContext, node)); | ||
assert.lengthOf(checkContext._relatedNodes, 1); | ||
assert.deepEqual(checkContext._relatedNodes, [node.querySelector('p')]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result of this looks like it is being ignored–there are 3 ids of target
, and the result doesn't seem to include anything about the one inside the Shadow DOM. To me it seems like it should be ignored, but I wasn't sure how the <slot>
came into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDs are scoped to their respective root. In this example, the div
and p
both have document
as the root, and so p
is the duplicate in this example. But because span
is in the shadow tree, it can have an ID that already exists in the document (or even in another shadow tree).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the description of the test is just confusing? it should not ignore slotted elements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the description of the test because it describes what is actually happening i.e. that the slotted content (light DOM) is being compared with the light DOM and not the shadow DOM it is slotted into. You could slightly clarify it by saying
Compare slotted content with the light DOM
test/checks/shared/duplicate-id.js
Outdated
@@ -58,4 +58,52 @@ describe('duplicate-id', function () { | |||
assert.isTrue(checks['duplicate-id'].evaluate.call(checkContext, node)); | |||
}); | |||
|
|||
(shadowSupport.v1 ? it : xit)('should find duplicate IDs in shadow trees', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A slightly more accurate test description would be
Should find duplicate IDs in the same shadow DOM
test/checks/shared/duplicate-id.js
Outdated
assert.deepEqual(checkContext._relatedNodes, [shadow.querySelector('p')]); | ||
}); | ||
|
||
(shadowSupport.v1 ? it : xit)('should ignore same IDs in shadow trees', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to
Should ignore duplicate IDs if they are in different document roots
|
||
assert.isFalse(checks['duplicate-id'].evaluate.call(checkContext, node)); | ||
assert.lengthOf(checkContext._relatedNodes, 1); | ||
assert.deepEqual(checkContext._relatedNodes, [node.querySelector('p')]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the description of the test because it describes what is actually happening i.e. that the slotted content (light DOM) is being compared with the light DOM and not the shadow DOM it is slotted into. You could slightly clarify it by saying
Compare slotted content with the light DOM
@WilcoFiers also, you will need to rebase this change onto the shadowDOM branch because it seems to regress some of the tests on the region shadow DOM implementation. |
e2b7b39
to
5b1cc7a
Compare
Updated the text and rebased. |
Closes #429.