OLD | NEW |
1 Polymer.Base._addFeature({ | 1 Polymer.Base._addFeature({ |
2 _prepTemplate: function () { | 2 _prepTemplate: function () { |
3 if (this._template === undefined) { | 3 if (this._template === undefined) { |
4 this._template = Polymer.DomModule.import(this.is, 'template'); | 4 this._template = Polymer.DomModule.import(this.is, 'template'); |
5 } | 5 } |
6 if (this._template && this._template.hasAttribute('is')) { | 6 if (this._template && this._template.hasAttribute('is')) { |
7 this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not
be a type-extension, found', this._template, 'Move inside simple <template>.'))
; | 7 this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not
be a type-extension, found', this._template, 'Move inside simple <template>.'))
; |
8 } | 8 } |
9 if (this._template && !this._template.content && window.HTMLTemplateElement && H
TMLTemplateElement.decorate) { | 9 if (this._template && !this._template.content && window.HTMLTemplateElement && H
TMLTemplateElement.decorate) { |
10 HTMLTemplateElement.decorate(this._template); | 10 HTMLTemplateElement.decorate(this._template); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 this._beginDistribute(); | 66 this._beginDistribute(); |
67 var c$ = this._clients; | 67 var c$ = this._clients; |
68 if (c$) { | 68 if (c$) { |
69 for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) { | 69 for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) { |
70 c._ready(); | 70 c._ready(); |
71 } | 71 } |
72 } | 72 } |
73 this._finishDistribute(); | 73 this._finishDistribute(); |
74 }, | 74 }, |
75 _readySelf: function () { | 75 _readySelf: function () { |
76 this._doBehavior('ready'); | 76 for (var i = 0, b; i < this.behaviors.length; i++) { |
| 77 b = this.behaviors[i]; |
| 78 if (b.ready) { |
| 79 b.ready.call(this); |
| 80 } |
| 81 } |
| 82 if (this.ready) { |
| 83 this.ready(); |
| 84 } |
77 this._readied = true; | 85 this._readied = true; |
78 if (this._attachedPending) { | 86 if (this._attachedPending) { |
79 this._attachedPending = false; | 87 this._attachedPending = false; |
80 this.attachedCallback(); | 88 this.attachedCallback(); |
81 } | 89 } |
82 }, | 90 }, |
83 _beforeClientsReady: function () { | 91 _beforeClientsReady: function () { |
84 }, | 92 }, |
85 _afterClientsReady: function () { | 93 _afterClientsReady: function () { |
86 }, | 94 }, |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 var DomApi = Polymer.DomApi; | 687 var DomApi = Polymer.DomApi; |
680 var dom = DomApi.factory; | 688 var dom = DomApi.factory; |
681 var TreeApi = Polymer.TreeApi; | 689 var TreeApi = Polymer.TreeApi; |
682 var getInnerHTML = Polymer.domInnerHTML.getInnerHTML; | 690 var getInnerHTML = Polymer.domInnerHTML.getInnerHTML; |
683 var CONTENT = DomApi.CONTENT; | 691 var CONTENT = DomApi.CONTENT; |
684 if (Settings.useShadow) { | 692 if (Settings.useShadow) { |
685 return; | 693 return; |
686 } | 694 } |
687 var nativeCloneNode = Element.prototype.cloneNode; | 695 var nativeCloneNode = Element.prototype.cloneNode; |
688 var nativeImportNode = Document.prototype.importNode; | 696 var nativeImportNode = Document.prototype.importNode; |
689 Polymer.Base.extend(DomApi.prototype, { | 697 Polymer.Base.mixin(DomApi.prototype, { |
690 _lazyDistribute: function (host) { | 698 _lazyDistribute: function (host) { |
691 if (host.shadyRoot && host.shadyRoot._distributionClean) { | 699 if (host.shadyRoot && host.shadyRoot._distributionClean) { |
692 host.shadyRoot._distributionClean = false; | 700 host.shadyRoot._distributionClean = false; |
693 Polymer.dom.addDebouncer(host.debounce('_distribute', host._distributeContent)); | 701 Polymer.dom.addDebouncer(host.debounce('_distribute', host._distributeContent)); |
694 } | 702 } |
695 }, | 703 }, |
696 appendChild: function (node) { | 704 appendChild: function (node) { |
697 return this.insertBefore(node); | 705 return this.insertBefore(node); |
698 }, | 706 }, |
699 insertBefore: function (node, ref_node) { | 707 insertBefore: function (node, ref_node) { |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 return Boolean(root && root._insertionPoints.length); | 1151 return Boolean(root && root._insertionPoints.length); |
1144 }; | 1152 }; |
1145 }());(function () { | 1153 }());(function () { |
1146 'use strict'; | 1154 'use strict'; |
1147 var Settings = Polymer.Settings; | 1155 var Settings = Polymer.Settings; |
1148 var TreeApi = Polymer.TreeApi; | 1156 var TreeApi = Polymer.TreeApi; |
1149 var DomApi = Polymer.DomApi; | 1157 var DomApi = Polymer.DomApi; |
1150 if (!Settings.useShadow) { | 1158 if (!Settings.useShadow) { |
1151 return; | 1159 return; |
1152 } | 1160 } |
1153 Polymer.Base.extend(DomApi.prototype, { | 1161 Polymer.Base.mixin(DomApi.prototype, { |
1154 querySelectorAll: function (selector) { | 1162 querySelectorAll: function (selector) { |
1155 return TreeApi.arrayCopy(this.node.querySelectorAll(selector)); | 1163 return TreeApi.arrayCopy(this.node.querySelectorAll(selector)); |
1156 }, | 1164 }, |
1157 getOwnerRoot: function () { | 1165 getOwnerRoot: function () { |
1158 var n = this.node; | 1166 var n = this.node; |
1159 while (n) { | 1167 while (n) { |
1160 if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE && n.host) { | 1168 if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE && n.host) { |
1161 return n; | 1169 return n; |
1162 } | 1170 } |
1163 n = n.parentNode; | 1171 n = n.parentNode; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 'parentNode', | 1261 'parentNode', |
1254 'firstChild', | 1262 'firstChild', |
1255 'lastChild', | 1263 'lastChild', |
1256 'nextSibling', | 1264 'nextSibling', |
1257 'previousSibling', | 1265 'previousSibling', |
1258 'firstElementChild', | 1266 'firstElementChild', |
1259 'lastElementChild', | 1267 'lastElementChild', |
1260 'nextElementSibling', | 1268 'nextElementSibling', |
1261 'previousElementSibling' | 1269 'previousElementSibling' |
1262 ]); | 1270 ]); |
1263 }());Polymer.Base.extend(Polymer.dom, { | 1271 }());Polymer.Base.mixin(Polymer.dom, { |
1264 _flushGuard: 0, | 1272 _flushGuard: 0, |
1265 _FLUSH_MAX: 100, | 1273 _FLUSH_MAX: 100, |
1266 _needsTakeRecords: !Polymer.Settings.useNativeCustomElements, | 1274 _needsTakeRecords: !Polymer.Settings.useNativeCustomElements, |
1267 _debouncers: [], | 1275 _debouncers: [], |
1268 _staticFlushList: [], | 1276 _staticFlushList: [], |
1269 _finishDebouncer: null, | 1277 _finishDebouncer: null, |
1270 flush: function () { | 1278 flush: function () { |
1271 this._flushGuard = 0; | 1279 this._flushGuard = 0; |
1272 this._prepareFlush(); | 1280 this._prepareFlush(); |
1273 while (this._debouncers.length && this._flushGuard < this._FLUSH_MAX) { | 1281 while (this._debouncers.length && this._flushGuard < this._FLUSH_MAX) { |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 }, | 1562 }, |
1555 _callListener: function (listener, info) { | 1563 _callListener: function (listener, info) { |
1556 return listener.fn.call(this.node, info); | 1564 return listener.fn.call(this.node, info); |
1557 }, | 1565 }, |
1558 enableShadowAttributeTracking: function () { | 1566 enableShadowAttributeTracking: function () { |
1559 } | 1567 } |
1560 }; | 1568 }; |
1561 if (Settings.useShadow) { | 1569 if (Settings.useShadow) { |
1562 var baseSetup = DomApi.EffectiveNodesObserver.prototype._setup; | 1570 var baseSetup = DomApi.EffectiveNodesObserver.prototype._setup; |
1563 var baseCleanup = DomApi.EffectiveNodesObserver.prototype._cleanup; | 1571 var baseCleanup = DomApi.EffectiveNodesObserver.prototype._cleanup; |
1564 Polymer.Base.extend(DomApi.EffectiveNodesObserver.prototype, { | 1572 Polymer.Base.mixin(DomApi.EffectiveNodesObserver.prototype, { |
1565 _setup: function () { | 1573 _setup: function () { |
1566 if (!this._observer) { | 1574 if (!this._observer) { |
1567 var self = this; | 1575 var self = this; |
1568 this._mutationHandler = function (mxns) { | 1576 this._mutationHandler = function (mxns) { |
1569 if (mxns && mxns.length) { | 1577 if (mxns && mxns.length) { |
1570 self._scheduleNotify(); | 1578 self._scheduleNotify(); |
1571 } | 1579 } |
1572 }; | 1580 }; |
1573 this._observer = new MutationObserver(this._mutationHandler); | 1581 this._observer = new MutationObserver(this._mutationHandler); |
1574 this._boundFlush = function () { | 1582 this._boundFlush = function () { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 }); | 1624 }); |
1617 } | 1625 } |
1618 }());(function () { | 1626 }());(function () { |
1619 'use strict'; | 1627 'use strict'; |
1620 var DomApi = Polymer.DomApi.ctor; | 1628 var DomApi = Polymer.DomApi.ctor; |
1621 var Settings = Polymer.Settings; | 1629 var Settings = Polymer.Settings; |
1622 DomApi.DistributedNodesObserver = function (domApi) { | 1630 DomApi.DistributedNodesObserver = function (domApi) { |
1623 DomApi.EffectiveNodesObserver.call(this, domApi); | 1631 DomApi.EffectiveNodesObserver.call(this, domApi); |
1624 }; | 1632 }; |
1625 DomApi.DistributedNodesObserver.prototype = Object.create(DomApi.EffectiveNodesO
bserver.prototype); | 1633 DomApi.DistributedNodesObserver.prototype = Object.create(DomApi.EffectiveNodesO
bserver.prototype); |
1626 Polymer.Base.extend(DomApi.DistributedNodesObserver.prototype, { | 1634 Polymer.Base.mixin(DomApi.DistributedNodesObserver.prototype, { |
1627 _setup: function () { | 1635 _setup: function () { |
1628 }, | 1636 }, |
1629 _cleanup: function () { | 1637 _cleanup: function () { |
1630 }, | 1638 }, |
1631 _beforeCallListeners: function () { | 1639 _beforeCallListeners: function () { |
1632 }, | 1640 }, |
1633 _getEffectiveNodes: function () { | 1641 _getEffectiveNodes: function () { |
1634 return this.domApi.getDistributedNodes(); | 1642 return this.domApi.getDistributedNodes(); |
1635 } | 1643 } |
1636 }); | 1644 }); |
1637 if (Settings.useShadow) { | 1645 if (Settings.useShadow) { |
1638 Polymer.Base.extend(DomApi.DistributedNodesObserver.prototype, { | 1646 Polymer.Base.mixin(DomApi.DistributedNodesObserver.prototype, { |
1639 _setup: function () { | 1647 _setup: function () { |
1640 if (!this._observer) { | 1648 if (!this._observer) { |
1641 var root = this.domApi.getOwnerRoot(); | 1649 var root = this.domApi.getOwnerRoot(); |
1642 var host = root && root.host; | 1650 var host = root && root.host; |
1643 if (host) { | 1651 if (host) { |
1644 var self = this; | 1652 var self = this; |
1645 this._observer = Polymer.dom(host).observeNodes(function () { | 1653 this._observer = Polymer.dom(host).observeNodes(function () { |
1646 self._scheduleNotify(); | 1654 self._scheduleNotify(); |
1647 }); | 1655 }); |
1648 this._observer._isContentListener = true; | 1656 this._observer._isContentListener = true; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 this.shadyRoot._dirtyRoots = []; | 1714 this.shadyRoot._dirtyRoots = []; |
1707 var i$ = this.shadyRoot._insertionPoints = !this._notes || this._notes._hasConte
nt ? this.shadyRoot.querySelectorAll('content') : []; | 1715 var i$ = this.shadyRoot._insertionPoints = !this._notes || this._notes._hasConte
nt ? this.shadyRoot.querySelectorAll('content') : []; |
1708 TreeApi.Logical.saveChildNodes(this.shadyRoot); | 1716 TreeApi.Logical.saveChildNodes(this.shadyRoot); |
1709 for (var i = 0, c; i < i$.length; i++) { | 1717 for (var i = 0, c; i < i$.length; i++) { |
1710 c = i$[i]; | 1718 c = i$[i]; |
1711 TreeApi.Logical.saveChildNodes(c); | 1719 TreeApi.Logical.saveChildNodes(c); |
1712 TreeApi.Logical.saveChildNodes(c.parentNode); | 1720 TreeApi.Logical.saveChildNodes(c.parentNode); |
1713 } | 1721 } |
1714 this.shadyRoot.host = this; | 1722 this.shadyRoot.host = this; |
1715 }, | 1723 }, |
1716 get domHost() { | |
1717 var root = Polymer.dom(this).getOwnerRoot(); | |
1718 return root && root.host; | |
1719 }, | |
1720 distributeContent: function (updateInsertionPoints) { | 1724 distributeContent: function (updateInsertionPoints) { |
1721 if (this.shadyRoot) { | 1725 if (this.shadyRoot) { |
1722 this.shadyRoot._invalidInsertionPoints = this.shadyRoot._invalidInsertionPoints
|| updateInsertionPoints; | 1726 this.shadyRoot._invalidInsertionPoints = this.shadyRoot._invalidInsertionPoints
|| updateInsertionPoints; |
1723 var host = getTopDistributingHost(this); | 1727 var host = getTopDistributingHost(this); |
1724 Polymer.dom(this)._lazyDistribute(host); | 1728 Polymer.dom(this)._lazyDistribute(host); |
1725 } | 1729 } |
1726 }, | 1730 }, |
1727 _distributeContent: function () { | 1731 _distributeContent: function () { |
1728 if (this._useContent && !this.shadyRoot._distributionClean) { | 1732 if (this._useContent && !this.shadyRoot._distributionClean) { |
1729 if (this.shadyRoot._invalidInsertionPoints) { | 1733 if (this.shadyRoot._invalidInsertionPoints) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 if (!validSelectors.test(select)) { | 1900 if (!validSelectors.test(select)) { |
1897 return false; | 1901 return false; |
1898 } | 1902 } |
1899 return this.elementMatches(select, node); | 1903 return this.elementMatches(select, node); |
1900 }, | 1904 }, |
1901 _elementAdd: function () { | 1905 _elementAdd: function () { |
1902 }, | 1906 }, |
1903 _elementRemove: function () { | 1907 _elementRemove: function () { |
1904 } | 1908 } |
1905 }); | 1909 }); |
| 1910 var domHostDesc = { |
| 1911 get: function () { |
| 1912 var root = Polymer.dom(this).getOwnerRoot(); |
| 1913 return root && root.host; |
| 1914 }, |
| 1915 configurable: true |
| 1916 }; |
| 1917 Object.defineProperty(Polymer.Base, 'domHost', domHostDesc); |
| 1918 Polymer.BaseDescriptors.domHost = domHostDesc; |
1906 function distributeNodeInto(child, insertionPoint) { | 1919 function distributeNodeInto(child, insertionPoint) { |
1907 insertionPoint._distributedNodes.push(child); | 1920 insertionPoint._distributedNodes.push(child); |
1908 var points = child._destinationInsertionPoints; | 1921 var points = child._destinationInsertionPoints; |
1909 if (!points) { | 1922 if (!points) { |
1910 child._destinationInsertionPoints = [insertionPoint]; | 1923 child._destinationInsertionPoints = [insertionPoint]; |
1911 } else { | 1924 } else { |
1912 points.push(insertionPoint); | 1925 points.push(insertionPoint); |
1913 } | 1926 } |
1914 } | 1927 } |
1915 function clearDistributedDestinationInsertionPoints(content) { | 1928 function clearDistributedDestinationInsertionPoints(content) { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2129 this._endHosting(); | 2142 this._endHosting(); |
2130 } | 2143 } |
2131 this._marshalHostAttributes(); | 2144 this._marshalHostAttributes(); |
2132 this._setupDebouncers(); | 2145 this._setupDebouncers(); |
2133 this._marshalBehaviors(); | 2146 this._marshalBehaviors(); |
2134 this._tryReady(); | 2147 this._tryReady(); |
2135 }, | 2148 }, |
2136 _marshalBehavior: function (b) { | 2149 _marshalBehavior: function (b) { |
2137 } | 2150 } |
2138 }); | 2151 }); |
OLD | NEW |