shadow-dom

Using jQuery with shadow dom

家住魔仙堡 提交于 2019-11-30 19:19:09
问题 Here I have created elements with shadow dom. /* some preparing code */ this.createShadowRoot(); // creates shadow root, this refers to element Later in the code I would access the shadow dom that I have created. These work: this.shadowRoot.getElementById("...") this.shadowRoot.querySelector("...") However this does not: $("...", this.shadowRoot) Why is that? As a temporary solution t his works at the moment : $("...", this.shadowRoot.children) Is there a better/more elegant way to work with

How are Shadow DOM events from under <content> targeted?

半城伤御伤魂 提交于 2019-11-30 15:37:11
问题 I'm trying to understand what events that originate in light DOM look like when received in shadow DOM via a <content> element. I'm reading the Shadow DOM W3C Draft, and I don't entirely understand it but it sounds like events are to be "retargeted" from the point of view of the EventListener attachment. In the cases where event path is across multiple node trees, the event's information about the target of the event is adjusted in order to maintain encapsulation. Event retargeting is a

How can I access the host of a custom element

旧时模样 提交于 2019-11-30 15:31:34
问题 I have a custom element which itself hosts a custom element. <polymer-element name="flex-nonvisual"> <template> <polymer-flex-layout></polymer-flex-layout> </template> </polymer-element> Now in attached() (or some other callback) of PolymerFlexLayout I want to set the class attribute of the flex-nonvisual element. In Javascript the code looks like this.parentNode.host.classList.add('someclass'); In Dart in attached() (after the call to super.attached() ) this.parent is null and I couldn't

What does :host /deep/ selector mean?

前提是你 提交于 2019-11-30 11:07:57
Please explain in a straightforward way what :host /deep/ means: :host /deep/ .ui-autocomplete { width: 85%; } It is used to allow styling child components when using emulated view encapsulation. More about this can be found here: https://angular.io/guide/component-styles Btw /deep/ selector is now deprecated: The shadow-piercing descendant combinator is deprecated and support is being removed from major browsers and tools. As such we plan to drop support in Angular (for all 3 of /deep/, >>> and ::ng-deep). Until then ::ng-deep should be preferred for a broader compatibility with the tools.

Importing styles into a web component

元气小坏坏 提交于 2019-11-30 03:26:32
问题 What is the canonical way to import styles into a web component? The following gives me an error HTML element <link> is ignored in shadow tree : <template> <link rel="style" href="foo.css" /> <h1>foo</h1> </template> I am inserting this using shadow DOM using the following: var importDoc, navBarProto; importDoc = document.currentScript.ownerDocument; navBarProto = Object.create(HTMLElement.prototype); navBarProto.createdCallback = function() { var template, templateClone, shadow; template =

What does :host /deep/ selector mean?

被刻印的时光 ゝ 提交于 2019-11-29 16:25:45
问题 Please explain in a straightforward way what :host /deep/ means: :host /deep/ .ui-autocomplete { width: 85%; } 回答1: It is used to allow styling child components when using emulated view encapsulation. More about this can be found here: https://angular.io/guide/component-styles Btw /deep/ selector is now deprecated: The shadow-piercing descendant combinator is deprecated and support is being removed from major browsers and tools. As such we plan to drop support in Angular (for all 3 of /deep/,

slot selector limit in web component

爱⌒轻易说出口 提交于 2019-11-29 15:52:06
slot is good to make a reusable web component, however, it has a limit so far. What I faced is the style problem. You just can't define the style inside a component, even you know what the inject content's structure would be. Details found from my post in github here I write a component, and try to inject content through slot from the outside and try to add style to the specific content in the component's shadow root. Demo HTML file <my-navbar> <ul> <li>link1</li> <li>link2</li> <li>link3</li> </ul> </my-navbar> JS file customElements.define('my-navbar', class extends HTMLElement { constructor

How to access host element from within the shadow root using Shadow DOM v1?

泄露秘密 提交于 2019-11-29 15:28:25
Given an element contained in a shadow root, how can I get to the element that hosts the said shadow root? Is there a single way to accomplish this regardless of where an element is in the tree (i.e. given a reference to either element2 or element3 , get the reference to element1 )? element1 └ #shadow-root └ element2 └ element3 For Shadow DOM v1, you may use the getRootNode() method. Then get the host attribute: event.target.getRootNode().host You can keep iterating parentNode until you get the shadow root, and then get host . function getHostElement(el) { while (el.parentNode) el = el

Shadow DOM styling from the outside

廉价感情. 提交于 2019-11-29 13:22:29
I am searching a way to styling shadow DOM from the outside. For example, I would like to set the color of all text in all 'span.special' elements as RED. Including 'span.special' elements from shadow DOM. How I can do this? Previously there were ::shadow pseudo-element and /deep/ combinator aka >>> for this purpose. So I could write something like span.special, *::shadow span.special { color: red } But now ::shadow , /deep/ and >>> are deprecated. So, what do we have as a replacement of them? Well, @import is not a solution if you are working with library web component that you can't change .

Using JS to enter text, but if I input text in one text box, the value already entered is getting deleted

喜欢而已 提交于 2019-11-29 12:29:34
I have 3 text box in a row, and I am using JS to input the texts in the text boxes. But the problem is when I enter the text in one field, and go to second box to enter the text, the value from first text box is removed. we are using the below code to input text ((JavascriptExecutor) webDriver).executeScript( "arguments[0].setAttribute('value','"+inputText+"')", element); Try the following : String js = "arguments[0].setAttribute('value','"+inputText+"')" ((JavascriptExecutor) webDriver).executeScript(js, element); Ensure that the before the second and third text is being pushed the document