How can I tell if an element is in a shadow DOM?

If you call a ShadowRoot’s toString() method, it will return “[object ShadowRoot]”. According to this fact, here’s my approach: function isInShadow(node) { var parent = (node && node.parentNode); while(parent) { if(parent.toString() === “[object ShadowRoot]”) { return true; } parent = parent.parentNode; } return false; } EDIT Jeremy Banks suggests an approach in another style of … Read more

Difference between constructor and connectedCallback in custom elements v1

As already stated by Juvian in the comments: constructor() is called when the element is created. connectedCallback() is called when (after) the element is attached to the DOM. The constructor() call is not specific to Custom Elements, it occurs with any object creation (typically created with the new operator), and not only HTML Elements. In … Read more

Is it possible to access Shadow DOM elements through the parent document?

@int32_t is right in that Shadow DOM, by definition, is a way to fill a node with DOM that you want to hide from external sources (Encapsulation). The point is that you as the component author get to choose exactly which parts will be exposed to outside CSS or JavaScript and which will not. Unfortunately, … Read more

Does the shadow DOM replace ::before and ::after?

CSS Scoping spec author here. The answer is actually, officially… undefined! I didn’t think about this interaction when I was writing the Scoping spec. I’ll send an email to the list, and we’ll figure it out. Almost certainly, we’ll settle on whatever browsers currently do (which appears to be letting ::before/after work “as expected” even … Read more

Does Angular 2 use Shadow DOM or a Virtual DOM?

update Shadow DOM is now directly supported. original Angular2 doesn’t use shadow DOM (default) nor virtual DOM. With encapsulation: ViewEncapsulation.Emulated (default) there is no shadow DOM because style encapsulation is only emulated. encapsulation: ViewEncapsulation.Native enables shadow DOM on browsers that support it natively or it’s again emulated when the webcomponents polyfill is loaded. Shadow DOM … Read more

Style html,body from web component (Angular 2)

You need to change the way your component serves css using ViewEncapsulation. By default it’s set to Emulated and angular will add an attribute containing surrogate id and pre-process the style rules To change this behavior import ViewEncapsulation from ‘angular2/core’ and use it in component’s metadata: @Component({ … encapsulation: ViewEncapsulation.None, … })

What is the ::content/::slotted pseudo-element and how does it work?

The ::content pseudo-element is being replaced in future implementations of Web Components / Shadow DOM with the ::slotted pseudo-element. Likewise, the element targeted by this pseudo-element has changed from <content to <slot> in the latest version of the Shadow DOM specification. You can see related discussion about that change here. Currently browsers still support <content> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)