custom-element

Can I get a button in shadowDOM to submit a form not in shadowDom?

旧街凉风 提交于 2021-01-23 04:59:47
问题 I just ran into an interesting situation where I have a submit <button> inside the shadowDOM of a native custom element that is placed inside a <form> . <form id="one" action="" method="get"> <s-button>Select</s-button> #shadow-root <button>...</button> <button>Outside</button> </form> I also have a <button> as a direct child of the <form> . The child <button> causes the form to submit. But the <button> in the shadow-root does not. In a way I guess this makes sense. But has anyone figured out

Can I get a button in shadowDOM to submit a form not in shadowDom?

為{幸葍}努か 提交于 2021-01-23 04:59:37
问题 I just ran into an interesting situation where I have a submit <button> inside the shadowDOM of a native custom element that is placed inside a <form> . <form id="one" action="" method="get"> <s-button>Select</s-button> #shadow-root <button>...</button> <button>Outside</button> </form> I also have a <button> as a direct child of the <form> . The child <button> causes the form to submit. But the <button> in the shadow-root does not. In a way I guess this makes sense. But has anyone figured out

Can I get a button in shadowDOM to submit a form not in shadowDom?

僤鯓⒐⒋嵵緔 提交于 2021-01-23 04:58:52
问题 I just ran into an interesting situation where I have a submit <button> inside the shadowDOM of a native custom element that is placed inside a <form> . <form id="one" action="" method="get"> <s-button>Select</s-button> #shadow-root <button>...</button> <button>Outside</button> </form> I also have a <button> as a direct child of the <form> . The child <button> causes the form to submit. But the <button> in the shadow-root does not. In a way I guess this makes sense. But has anyone figured out

wait for Element Upgrade in connectedCallback: FireFox and Chromium differences

放肆的年华 提交于 2020-08-08 06:11:43
问题 Bitten again by this Chrome Element upgrade issue, after spending a week in FireFox. Forgot to wrap code in a setTimeout before delivering to Chromium browsers. FireFox prints: ABCD Chromium prints: ADCD Question: Why the difference? <script> customElements.define('my-element', class extends HTMLElement { connectedCallback() { console.log(this.innerHTML);// "A" in FireFox, "" in other Browsers if (this.innerHTML == "A") this.innerHTML = this.innerHTML + "B"; else setTimeout(() => this

::slotted CSS selector for nested children

て烟熏妆下的殇ゞ 提交于 2020-08-05 05:57:19
问题 The CSS ::slotted selector selects children of the <slot> element. however, when trying to select grandchildren like with ::slotted(*) , ::slotted(*) * , or ::slotted(* *) , the selector doesn't seem to take effect. class MyElement extends HTMLElement { constructor() { super(); const shadowRoot = this.attachShadow({mode: 'open'}) shadowRoot.innerHTML = ` <style> ::slotted(*) { display: block; border: solid blue 1px; padding: 3px; } ::slotted(*) span { display: block; border: solid red 1px;