From 1b942225cf6ca0ce9996904749aa9135582b2776 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Wed, 19 Feb 2014 13:59:42 -0800 Subject: [PATCH] add 'domReady' method. This method can be used to access elements in dom (descendants, ancestors, siblings) such that the developer is inured to upgrade ordering. If the element definitions have loaded, domReady can be used to access upgraded elements. --- src/instance/base.js | 10 +++++++ test/html/ctor.html | 60 +++++++++++++++++++++++++++++++++++++++++ test/html/domready.html | 45 +++++++++++++++++++++++++++++++ test/js/register.js | 2 ++ 4 files changed, 117 insertions(+) create mode 100644 test/html/ctor.html create mode 100644 test/html/domready.html diff --git a/src/instance/base.js b/src/instance/base.js index ad28959..13e5b7a 100644 --- a/src/instance/base.js +++ b/src/instance/base.js @@ -64,6 +64,16 @@ if (this.enteredView) { this.enteredView(); } + // NOTE: domReady can be used to access elements in dom (descendants, + // ancestors, siblings) such that the developer is enured to upgrade + // ordering. If the element definitions have loaded, domReady + // can be used to access upgraded elements. + if (!this.hasBeenAttached) { + this.hasBeenAttached = true; + if (this.domReady) { + this.async('domReady'); + } + } }, detachedCallback: function() { if (!this.preventDispose) { diff --git a/test/html/ctor.html b/test/html/ctor.html new file mode 100644 index 0000000..549b4c3 --- /dev/null +++ b/test/html/ctor.html @@ -0,0 +1,60 @@ + + + + constructor test + + + + + + + + + + + + + + + + + + + + + diff --git a/test/html/domready.html b/test/html/domready.html new file mode 100644 index 0000000..9e853f7 --- /dev/null +++ b/test/html/domready.html @@ -0,0 +1,45 @@ + + + + domReady test + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/js/register.js b/test/js/register.js index d5e01cf..b4a611e 100644 --- a/test/js/register.js +++ b/test/js/register.js @@ -52,4 +52,6 @@ htmlSuite('element registration', function() { htmlTest('html/element-registration.html'); htmlTest('html/element-import.html'); htmlTest('html/polymer-body.html'); + htmlTest('html/ctor.html'); + htmlTest('html/domready.html'); });