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

feat(duplicate-id): Add shadow DOM support #452

Merged
merged 3 commits into from
Aug 2, 2017
Merged

Conversation

WilcoFiers
Copy link
Contributor

Closes #429.


assert.isFalse(checks['duplicate-id'].evaluate.call(checkContext, node));
assert.lengthOf(checkContext._relatedNodes, 1);
assert.deepEqual(checkContext._relatedNodes, [node.querySelector('p')]);
Copy link
Contributor

@marcysutton marcysutton Jul 19, 2017

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.

Copy link
Contributor Author

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).

Copy link
Contributor

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

Copy link
Contributor

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

@@ -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 () {
Copy link
Contributor

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

assert.deepEqual(checkContext._relatedNodes, [shadow.querySelector('p')]);
});

(shadowSupport.v1 ? it : xit)('should ignore same IDs in shadow trees', function () {
Copy link
Contributor

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')]);
Copy link
Contributor

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

@dylanb
Copy link
Contributor

dylanb commented Jul 31, 2017

@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.

@WilcoFiers
Copy link
Contributor Author

Updated the text and rebased.

@dequelabs dequelabs deleted a comment from WilcoFiers Aug 2, 2017
@dylanb dylanb merged commit e910d57 into shadowDOM Aug 2, 2017
@marcysutton marcysutton deleted the sd/duplicate-id branch August 15, 2017 19:25
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.

3 participants