Polymer.dom(this).firstElementChild undefined

105 views
Skip to first unread message

John Jones

unread,
Jul 6, 2015, 7:10:53 PM7/6/15
to polym...@googlegroups.com
Whenever I try to use Polymer.dom(this).firstElementChild, it returns undefined.  By contrast, this.firstElementChild finds the element as I expect.

ready: function() {
  var child1 = Polymer.dom(this).firstElementChild; // undef
  var child2 = this.firstElementChild;  // finds my child element
  // do something with the child
}

I'm trying this because the docs for the DOM API (https://www.polymer-project.org/1.0/docs/devguide/local-dom.html#dom-api) says "All DOM manipulation must use this API, as opposed to DOM API directly on nodes."

Any ideas why this wouldn't be working?  Does the statement about not using DOM API directly really apply to properties like firstElementChild that don't manipulate the DOM?

Michael Giuffrida

unread,
Jul 6, 2015, 8:29:12 PM7/6/15
to John Jones, polymer-dev
Is your element in the light DOM or your element's local DOM (shady/shadow root)? If the latter, try Polymer.dom(this.root).firstElementChild.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/75309c99-de71-4ad3-af6a-8facd2129cd4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages