Skip to content

Commit

Permalink
Shadow tree and Iframe example for "Unique id" (3ea0c8) (#848)
Browse files Browse the repository at this point in the history
* Add aria-labelledby example and end example descriptions
* Add Accessibility Support about browsers not respecting empty alt (23a2a8) (#692)
* Add examples with shadow tree and iframe
  • Loading branch information
Jym77 committed Sep 25, 2019
1 parent cb57e07 commit 72e4f1a
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions _rules/id-value-unique-3ea0c8.md
Expand Up @@ -51,15 +51,15 @@ There are no major accessibility support issues known for this rule.

#### Passed Example 1

Only one `id` within the document context
There is only one `id` within the document context.

```html
<div id="my-div">This is my first element</div>
```

#### Passed Example 2

All `id`s are unique within the document context
All `id`s are unique within the document context.

```html
<div id="my-div1">This is my first element</div>
Expand All @@ -69,22 +69,32 @@ All `id`s are unique within the document context

#### Passed Example 3

`id` in shadow DOM is for the same element as `id` in light DOM
Two of the `id` are the same (`my-elt`), but they are in different trees (the first one in the [document tree](https://dom.spec.whatwg.org/#document-trees) and the second in the [shadow tree](https://dom.spec.whatwg.org/#shadow-trees)).

```html
<div id="my-elm"></div>
<div id="my-elt"></div>
<div id="host"></div>
<script>
var myElm = document.getElementById('my-elm')
var shadow = myElm.attachShadow({ mode: 'open' })
shadow.innerHTML = '<b id="my-elm" ><slot></slot></b>'
var host = document.getElementById('host')
var shadow = host.attachShadow({ mode: 'open' })
shadow.innerHTML = '<b id="my-elt"></b>'
</script>
```

#### Passed Example 4

Both `id` are the same (`my-elt`), but they are in different [document trees](https://dom.spec.whatwg.org/#document-trees) because the `iframe` is creating a new one.

```html
<div id="my-elt"></div>
<iframe srcdoc="<span id='my-elt'></span>"></iframe>
```

### Failed

#### Failed Example 1

Several elements have identical `id`
Several elements have identical `id`.

```html
<div id="my-div">This is my first element</div>
Expand All @@ -93,7 +103,7 @@ Several elements have identical `id`

#### Failed Example 2

Elements of different types have identical `id`
Elements of different types have identical `id`.

```html
<div id="my-div">This is my first element</div>
Expand All @@ -102,7 +112,7 @@ Elements of different types have identical `id`

#### Failed Example 3

Having `display: none` on an element still makes it applicable to this rule
Having `display: none` on an element still makes it applicable to this rule.

```html
<div id="my-div" style="display:none">This is my first element</div>
Expand All @@ -113,15 +123,15 @@ Having `display: none` on an element still makes it applicable to this rule

#### Inapplicable Example 1

No `id` on element
No `id` on element.

```html
<div>This is my first element</div>
```

#### Inapplicable Example 2

XML `id` not applicable to this rule
XML `id` not applicable to this rule.

```html
<div xml:id="my-div">This is my first element</div>
Expand Down

0 comments on commit 72e4f1a

Please sign in to comment.