diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/html/global_attributes%2Fis.html | |
new repository
Diffstat (limited to 'devdocs/html/global_attributes%2Fis.html')
| -rw-r--r-- | devdocs/html/global_attributes%2Fis.html | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/devdocs/html/global_attributes%2Fis.html b/devdocs/html/global_attributes%2Fis.html new file mode 100644 index 00000000..dab03631 --- /dev/null +++ b/devdocs/html/global_attributes%2Fis.html @@ -0,0 +1,79 @@ +<header><h1>is</h1></header><div class="section-content"> +<p>The <code>is</code> <a href="../global_attributes">global attribute</a> allows you to specify that a standard HTML element should behave like a defined custom built-in element (see <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements">Using custom elements</a> for more details).</p> <p>This attribute can only be used if the specified custom element name has been successfully <a href="https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define">defined</a> in the current document, and extends the element type it is being applied to.</p> +</div> +<h2 id="examples">Examples</h2> +<div class="section-content"> +<p>The following code is taken from our <a href="https://github.com/mdn/web-components-examples/tree/main/word-count-web-component" target="_blank">word-count-web-component</a> example (<a href="https://mdn.github.io/web-components-examples/word-count-web-component/" target="_blank">see it live also</a>).</p> <div class="code-example"> +<p class="example-header"><span class="language-name">js</span></p> +<pre data-signature="jVc95/umnT02cy/WQ+QXP/GX79Q/NzKV4VzHQjCaIMo=" data-language="js"><span class="token comment">// Create a class for the element</span> +<span class="token keyword">class</span> <span class="token class-name">WordCount</span> <span class="token keyword">extends</span> <span class="token class-name">HTMLParagraphElement</span> <span class="token punctuation">{</span> + <span class="token function">constructor</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> + <span class="token comment">// Always call super first in constructor</span> + <span class="token keyword">super</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> + + <span class="token comment">// Constructor contents omitted for brevity</span> + <span class="token comment">// …</span> + <span class="token punctuation">}</span> +<span class="token punctuation">}</span> + +<span class="token comment">// Define the new element</span> +customElements<span class="token punctuation">.</span><span class="token function">define</span><span class="token punctuation">(</span><span class="token string">"word-count"</span><span class="token punctuation">,</span> WordCount<span class="token punctuation">,</span> <span class="token punctuation">{</span> <span class="token keyword">extends</span><span class="token operator">:</span> <span class="token string">"p"</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span> +</pre> +</div> <div class="code-example"> +<p class="example-header"><span class="language-name">html</span></p> +<pre data-signature="2HWc9XXr7N6633Peud0V5KO5Agg7fFBZQXZH96uYCqM=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span> <span class="token attr-name">is</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>word-count<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span> +</pre> +</div> +</div> +<h2 id="specifications">Specifications</h2> +<div class="_table"><table class="standard-table"> +<thead><tr><th scope="col">Specification</th></tr></thead> +<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is">HTML Standard <br><small># attr-is</small></a></td></tr></tbody> +</table></div> +<h2 id="browser_compatibility">Browser compatibility</h2> +<div class="_table"><table> +<thead> +<tr id="bct-browser-type"> +<th></th> +<th colspan="6">Desktop</th> +<th colspan="6">Mobile</th> +</tr> +<tr id="bct-browsers"> +<th></th> +<th>Chrome</th> +<th>Edge</th> +<th>Firefox</th> +<th>Internet Explorer</th> +<th>Opera</th> +<th>Safari</th> +<th>WebView Android</th> +<th>Chrome Android</th> +<th>Firefox for Android</th> +<th>Opera Android</th> +<th>Safari on IOS</th> +<th>Samsung Internet</th> +</tr> +</thead> +<tbody><tr> +<th><code>is</code></th> +<td class="bc-supports-yes">67</td> +<td class="bc-supports-yes">79</td> +<td class="bc-supports-yes">63</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">54</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">67</td> +<td class="bc-supports-yes">67</td> +<td class="bc-supports-yes">63</td> +<td class="bc-supports-yes">48</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">9.0</td> +</tr></tbody> +</table></div> +<h2 id="see_also">See also</h2> +<div class="section-content"><ul> <li>All <a href="../global_attributes">global attributes</a>.</li> </ul></div><div class="_attribution"> + <p class="_attribution-p"> + © 2005–2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br> + <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/is" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/is</a> + </p> +</div> |
