|
15 | 15 | // TODO(sorvell): temporary BC |
16 | 16 | ready: function() { |
17 | 17 |
|
18 | | - }, |
19 | | - // TODO(sjmiles): temporary BC |
20 | | - readyCallback: function() { |
21 | | - this._createdCallback(); |
22 | 18 | }, |
23 | 19 | createdCallback: function() { |
24 | | - this._createdCallback(); |
| 20 | + if (this.ownerDocument.defaultView || this.forceReady || |
| 21 | + Polymer.preparingElements) { |
| 22 | + this.prepare(); |
| 23 | + } |
25 | 24 | }, |
26 | 25 | // system entry point, do not override |
27 | | - _createdCallback: function() { |
| 26 | + prepare: function() { |
| 27 | + if (this._prepared) { |
| 28 | + return; |
| 29 | + } |
| 30 | + this._prepared = true; |
28 | 31 | //this.style.display = 'inline-block'; |
29 | 32 | // install property observers |
30 | | - // do this first so we can observe changes during initialization |
31 | | - this.observeProperties(); |
32 | 33 | // install boilerplate attributes |
33 | 34 | this.copyInstanceAttributes(); |
34 | 35 | // process input attributes |
35 | 36 | this.takeAttributes(); |
| 37 | + // do this first so we can observe changes during initialization |
| 38 | + //this.observeProperties(); |
36 | 39 | // add event listeners |
37 | 40 | this.addHostListeners(); |
| 41 | + // forces sub-elements to be prepared |
| 42 | + Polymer.preparingElements = true; |
38 | 43 | // process declarative resources |
39 | 44 | this.parseElements(this.__proto__); |
| 45 | + Polymer.preparingElements = false; |
| 46 | + this.observeProperties(); |
| 47 | + //Platform.endOfMicrotask(this.initializeProperties.bind(this)); |
40 | 48 | // unless this element is inserted into the main document |
41 | 49 | // (or the user otherwise specifically prevents it) |
42 | 50 | // bindings will self destruct after a short time; this is |
|
45 | 53 | //this.asyncUnbindAll(); |
46 | 54 | // user initialization |
47 | 55 | // TODO(sorvell): bc |
| 56 | + //console.log('created', this); |
48 | 57 | this.ready(); |
49 | 58 | this.created(); |
50 | | - }, |
51 | | - insertedCallback: function() { |
52 | | - this._enteredDocumentCallback(); |
| 59 | + // TODO(sorvell): refactor so this doesn't depend on properties already |
| 60 | + // having been observed |
| 61 | + this.initializeProperties(); |
53 | 62 | }, |
54 | 63 | enteredDocumentCallback: function() { |
55 | | - this._enteredDocumentCallback(); |
56 | | - }, |
57 | | - _enteredDocumentCallback: function() { |
58 | | - this.cancelUnbindAll(true); |
59 | | - // TODO(sorvell): bc |
60 | | - if (this.inserted) { |
61 | | - this.inserted(); |
| 64 | + if (!this.forceReady) { |
| 65 | + this.prepare(); |
62 | 66 | } |
| 67 | + this.cancelUnbindAll(true); |
63 | 68 | // invoke user action |
64 | 69 | if (this.enteredDocument) { |
65 | 70 | this.enteredDocument(); |
66 | 71 | } |
67 | 72 | }, |
68 | | - removedCallback: function() { |
69 | | - this._leftDocumentCallback(); |
70 | | - }, |
71 | 73 | leftDocumentCallback: function() { |
72 | | - this._leftDocumentCallback(); |
73 | | - }, |
74 | | - _leftDocumentCallback: function() { |
75 | 74 | this.asyncUnbindAll(); |
76 | | - // TODO(sorvell): bc |
77 | | - if (this.removed) { |
78 | | - this.removed(); |
79 | | - } |
80 | 75 | // invoke user action |
81 | 76 | if (this.leftDocument) { |
82 | 77 | this.leftDocument(); |
|
0 commit comments