ElementInternals-reportValidity-delegatesFocus-notref.html (749B)
1 <!DOCTYPE html> 2 <title>Custom element with delegatesFocus in Form should show validation message on focus delegated element</title> 3 <link rel=help href=https://html.spec.whatwg.org/C/#report-validity-steps> 4 5 <form> 6 <input-custom-element></input-custom-element> 7 </form> 8 9 <script> 10 class InputCustomElement extends HTMLElement { 11 constructor() { 12 super(); 13 14 this.attachShadow({ 15 mode: "open", 16 delegatesFocus: true 17 }); 18 this.shadowRoot.innerHTML = '<input>'; 19 this.elementInternals = this.attachInternals(); 20 this.elementInternals.setValidity({valueMissing: true}, 'value missing'); 21 } 22 23 static get formAssociated() { 24 return true; 25 } 26 } 27 28 customElements.define("input-custom-element", InputCustomElement); 29 30 </script>