@@ -313,29 +313,29 @@ Possiamo estedere e personalizzare gli elementi HTML built-in ereditando dalle l
313313
314314Per esempio, i pulsanti sono una istanza di ` HTMLButtonElement ` , lo quello andiamo a costruirci sopra.
315315
316- 1 . Extend ` HTMLButtonElement ` with our class :
316+ 1 . Estendiamo il ` HTMLButtonElement ` con la nostra classe :
317317
318318 ``` js
319- class HelloButton extends HTMLButtonElement { /* custom element methods */ }
319+ class HelloButton extends HTMLButtonElement { /* metodi degli elementi personalizzati */ }
320320 ```
321321
322- 2. Provide the third argument to ` customElements.define` , that specifies the tag:
322+ 2. Fornisceil terzo argomenti a ` customElements.define` , che specifia il tag:
323323 ` ` ` js
324324 customElements.define('hello-button', HelloButton, *!*{extends: 'button'}*/!*);
325325 ` ` `
326326
327- There may be different tags that share the same DOM - class , that ' s why specifying `extends` is needed .
327+ Possono esserci tag differenti che condividono la stessa classe DOM , ecco perché è necessario specificare ` extends` .
328328
329- 3. At the end, to use our custom element, insert a regular `<button>` tag, but add `is="hello-button"` to it :
329+ 3. Alla fine, per usare il nostro elemento personalizzato, inseriamo un normale tag ` <button>` , aggiungendoc però l ' attributo `is="hello-button"`:
330330 ```html
331331 <button is="hello-button">...</button>
332332 ```
333333
334- Here ' s a full example :
334+ Ecco l ' esempio completo :
335335
336336` ` ` html run autorun="no-epub"
337337<script>
338- // The button that says "hello" on click
338+ // Il pulsante dice "hello" al click
339339class HelloButton extends HTMLButtonElement {
340340*!*
341341 constructor() {
@@ -351,28 +351,28 @@ customElements.define('hello-button', HelloButton, {extends: 'button'});
351351</script>
352352
353353*!*
354- <button is="hello-button">Click me </button>
354+ <button is="hello-button">Cliccami </button>
355355*/!*
356356
357357*!*
358- <button is="hello-button" disabled>Disabled </button>
358+ <button is="hello-button" disabled>Disabilitato </button>
359359*/!*
360360` ` `
361361
362- Our new button extends the built- in one . So it keeps the same styles and standard features like ` disabled` attribute .
362+ Il nostro nuovo pulsante estende quello built- in . Quindi mantiene gli stessi stili e caratteristiche standard come l ' attributo `disabled`.
363363
364- ## References
364+ ## Riferimenti
365365
366366- HTML Living Standard: <https://html.spec.whatwg.org/#custom-elements>.
367- - Compatiblity : < https: // caniuse.com/#feat=custom-elements>.
367+ - Compatibilità : <https://caniuse.com/#feat=custom-elements>.
368368
369- ## Summary
369+ ## Riepilogo
370370
371- Custom elements can be of two types :
371+ Gli elementi personalizzati possono essere di due tipi :
372372
373- 1. " Autonomous " -- new tags , extending ` HTMLElement` .
373+ 1. "Autonomi " -- nuovi tag che estendono `HTMLElement`.
374374
375- Definition scheme :
375+ Schema di definizione :
376376
377377 ```js
378378 class MyElement extends HTMLElement {
@@ -387,13 +387,13 @@ Custom elements can be of two types:
387387 /* <my-element> */
388388 ```
389389
390- 2. " Customized built-in elements " -- extensions of existing elements .
390+ 2. "Elementi built-in personalizzati " -- estensione di elementi esistenti .
391391
392- Requires one more ` .define` argument, and ` is="..."` in HTML :
392+ Richede un argomento `.define` aggiuntivo, e `is="..."` dentro l ' HTML :
393393 ` ` ` js
394394 class MyButton extends HTMLButtonElement { /*...*/ }
395395 customElements.define('my-button', MyElement, {extends: 'button'});
396396 /* <button is="my-button"> */
397397 ` ` `
398398
399- Custom elements are well - supported among browsers . Edge is a bit behind, but there ' s a polyfill <https://github.com/webcomponents/polyfills/tree/master/packages/webcomponentsjs>.
399+ Gli elementi sono ben supportati nei vari browser . Per i browser che non la supportano esistono un polyfill < https: // github.com/webcomponents/polyfills/tree/master/packages/webcomponentsjs>.
0 commit comments