How can I access the host of a custom element

Günter Zöchbauer

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 find any other reference to the host element.

How can I do this in Dart?

Günter Zöchbauer

update: Polymer >=1.0.x

shady DOM

new PolymerDom(this).parentNode;

or

domHost

short for

Polymer.dom(this).getOwnerRoot().host   

full shadow DOM

(this.parentNode as ShadowRoot).host

@ChristopheHerreman and @MattB are still right about encapsulation should not be broken.

But also JS Polymer elements access the parent in their layout elements because it's still convenient in some scenarios.

This works now in PolymerDart too.

Polymer.dart <= 0.16.x

(this.parentNode as ShadowRoot).host

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I access the host of a custom element

From Dev

How can I access detox element matchers in custom helpers?

From Java

How can i check whether an element can host Shadow DOM?

From Dev

How can I access the children of a panel element?

From Dev

how can I access to a specific element in json

From Dev

How can I access the children of a panel element?

From Dev

How can I access a property of an html element?

From Dev

How can I access Apache (on VirtualBox guest) from host?

From Dev

From a virtual machine, how can't I access the host by name?

From Dev

Ansible: How can I access a variable of other host?

From Dev

How can I access element reference from *ngFor loop element?

From Dev

How can I access a VirtualBox host-only network from outside the host machine?

From Dev

Using Vagrant, how can I access an apache virtual host from the host OS's web browser

From Dev

How can I load in a bootbox a custom element with javascript methods attached?

From Dev

How can i make custom Polymer element hidden?

From Dev

How can I pass attribute to an imported hidden custom polymer element

From Dev

How can i make custom Polymer element hidden?

From Dev

How can I access a custom section in a Pyramid .ini file?

From Dev

How can I access JMeter variables inside a custom java sampler?

From Dev

how can i access custom headers from an htaccess file?

From Dev

How can I access path variables in my custom HandlerMethodArgumentResolver

From Dev

How can I access other PropertyValues at runtime with a custom PropertyValueEditor

From Dev

How can I access a custom object inside an exception?

From Dev

How can I access the HTTP headers in a custom error document?

From Dev

How can I access the previous/next element in an ArrayList?

From Dev

In R, how can I access the first element of each level of a factor?

From Dev

How can I access each element of a pair in a pair list?

From Dev

php and nested json: how can i access this element?

From Dev

How can i access element value in SOAP response with lxml objectify

Related Related

  1. 1

    How can I access the host of a custom element

  2. 2

    How can I access detox element matchers in custom helpers?

  3. 3

    How can i check whether an element can host Shadow DOM?

  4. 4

    How can I access the children of a panel element?

  5. 5

    how can I access to a specific element in json

  6. 6

    How can I access the children of a panel element?

  7. 7

    How can I access a property of an html element?

  8. 8

    How can I access Apache (on VirtualBox guest) from host?

  9. 9

    From a virtual machine, how can't I access the host by name?

  10. 10

    Ansible: How can I access a variable of other host?

  11. 11

    How can I access element reference from *ngFor loop element?

  12. 12

    How can I access a VirtualBox host-only network from outside the host machine?

  13. 13

    Using Vagrant, how can I access an apache virtual host from the host OS's web browser

  14. 14

    How can I load in a bootbox a custom element with javascript methods attached?

  15. 15

    How can i make custom Polymer element hidden?

  16. 16

    How can I pass attribute to an imported hidden custom polymer element

  17. 17

    How can i make custom Polymer element hidden?

  18. 18

    How can I access a custom section in a Pyramid .ini file?

  19. 19

    How can I access JMeter variables inside a custom java sampler?

  20. 20

    how can i access custom headers from an htaccess file?

  21. 21

    How can I access path variables in my custom HandlerMethodArgumentResolver

  22. 22

    How can I access other PropertyValues at runtime with a custom PropertyValueEditor

  23. 23

    How can I access a custom object inside an exception?

  24. 24

    How can I access the HTTP headers in a custom error document?

  25. 25

    How can I access the previous/next element in an ArrayList?

  26. 26

    In R, how can I access the first element of each level of a factor?

  27. 27

    How can I access each element of a pair in a pair list?

  28. 28

    php and nested json: how can i access this element?

  29. 29

    How can i access element value in SOAP response with lxml objectify

HotTag

Archive