lifecycle callback triggers

43 views
Skip to first unread message

johnj...@chromium.org

unread,
Mar 5, 2014, 2:39:22 PM3/5/14
to polym...@googlegroups.com
Hi, I'm trying to understand the lifecycle callbacks in the demo app 'pica'.

If I set a break point in components/polymer-elements.js createdCallback:

  var prototype = extend(Object.create(HTMLElement.prototype), {

    createdCallback: function() {
      if (this.getAttribute('name')) {
        this.init();
      }
    },

Then the call stack is:
d.createdCallback (polymer-element.js:22)
(anonymous function) (polymer-element.js:147)
(anonymous function) (polymer-element.js:147)

where 147 is:
 document.registerElement('polymer-element', {prototype: prototype});

In the function createdCallback, 'this' is an HTMElement with local name 'polymer-element'. 

I expected this callback when an instance of the custom element 'polymer-element' is created, not when the type is registered. I could not find anything in the spec to suggest that registration should have this effect.

What do you expect here?
jjb

Scott Miles

unread,
Mar 5, 2014, 2:53:52 PM3/5/14
to johnjbarton, polymer-dev
Calling `document.registerElement()` results in immediate (synchronous) upgrade of all matching elements extant in DOM.

Scott


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/03ff8bd4-89a9-4dd7-ac5f-f54043375d8b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

johnj...@chromium.org

unread,
Mar 5, 2014, 2:58:04 PM3/5/14
to polym...@googlegroups.com, johnjbarton
Ok thanks!  
Reply all
Reply to author
Forward
0 new messages