mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Doc instance props isAttached, rootPath, importPath. Fix early rootPath. Fixes #3956
This commit is contained in:
@@ -33,6 +33,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* @polymerMixin
|
||||
* @mixes Polymer.ElementMixin
|
||||
* @mixes Polymer.GestureEventListeners
|
||||
* @property isAttached {boolean} Set to `true` in this element's
|
||||
* `connectedCallback` and `false` in `disconnectedCallback`
|
||||
* @memberof Polymer
|
||||
* @summary Element class mixin that provides Polymer's "legacy" API
|
||||
*/
|
||||
|
||||
@@ -103,6 +103,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* @polymerMixin
|
||||
* @mixes Polymer.PropertyEffects
|
||||
* @memberof Polymer
|
||||
* @property rootPath {string} Set to the value of `Polymer.rootPath`,
|
||||
* which defaults to the main document path
|
||||
* @property importPath {string} Set to the value of the class's static
|
||||
* `importPath` property, which defaults to the path of this element's
|
||||
* `dom-module` (when `is` is used), but can be overridden for other
|
||||
* import strategies.
|
||||
* @summary Element class mixin that provides the core API for Polymer's
|
||||
* meta-programming features.
|
||||
*/
|
||||
|
||||
@@ -102,8 +102,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
pathFromUrl: pathFromUrl
|
||||
};
|
||||
|
||||
// NOTE: baseURI is not supported on IE?
|
||||
Polymer.rootPath = pathFromUrl(document.baseURI || window.location.href);
|
||||
// NOTE: baseURI is not supported on IE
|
||||
Polymer.rootPath = Polymer.rootPath ||
|
||||
pathFromUrl(document.baseURI || window.location.href);
|
||||
|
||||
})();
|
||||
|
||||
|
||||
@@ -15,28 +15,36 @@
|
||||
}
|
||||
static get observers() { return ['propChanged(prop)']}
|
||||
propChanged() {
|
||||
console.log('propChanged', this.localName, this.shadowRoot);
|
||||
console.log(this.localName, 'propChanged', this.shadowRoot);
|
||||
}
|
||||
constructor() {
|
||||
console.log('constructed', 'x-a');
|
||||
console.log('x-a', 'constructed');
|
||||
super();
|
||||
this.childList = [];
|
||||
this.addEventListener('child-is-here', e => {
|
||||
let target = e.composedPath()[0];
|
||||
if (target !== this) {
|
||||
this.childList.push(target);
|
||||
}
|
||||
});
|
||||
this.prop = 'prop';
|
||||
}
|
||||
connectedCallback() {
|
||||
console.group('connected', this.localName);
|
||||
console.group(this.localName, 'connected');
|
||||
super.connectedCallback();
|
||||
console.warn('connected (user)', this.localName, this.shadowRoot);
|
||||
console.groupEnd('connected', this.localName);
|
||||
console.warn(this.localName, 'connected (user)', this.shadowRoot);
|
||||
console.groupEnd(this.localName, 'connected');
|
||||
}
|
||||
_flushProperties() {
|
||||
console.log('flush', this.localName);
|
||||
console.log(this.localName, 'flush');
|
||||
super._flushProperties();
|
||||
}
|
||||
ready() {
|
||||
console.group('ready', this.localName);
|
||||
console.group(this.localName, 'ready');
|
||||
super.ready();
|
||||
console.warn('ready (user)', this.localName, this.shadowRoot);
|
||||
console.groupEnd('ready', this.localName);
|
||||
console.warn(this.localName, 'ready (user)', this.shadowRoot);
|
||||
console.log(this.localName, 'childList', this.childList);
|
||||
console.groupEnd(this.localName, 'ready');
|
||||
}
|
||||
}
|
||||
customElements.define('x-a', XA);
|
||||
@@ -47,27 +55,36 @@
|
||||
}
|
||||
static get observers() { return ['propChanged(prop)']}
|
||||
propChanged() {
|
||||
console.log('propChanged', this.localName, this.shadowRoot);
|
||||
console.log(this.localName, 'propChanged', this.shadowRoot);
|
||||
}
|
||||
constructor() {
|
||||
console.log('constructed', 'x-b');
|
||||
console.log('x-b', 'constructed');
|
||||
super();
|
||||
this.childList = [];
|
||||
this.addEventListener('child-is-here', e => {
|
||||
let target = e.composedPath()[0];
|
||||
if (target !== this) {
|
||||
this.childList.push(target);
|
||||
}
|
||||
});
|
||||
}
|
||||
connectedCallback() {
|
||||
console.group('connected', this.localName);
|
||||
console.group(this.localName, 'connected');
|
||||
super.connectedCallback();
|
||||
console.warn('connected (user)', this.localName, this.shadowRoot);
|
||||
console.groupEnd('connected', this.localName);
|
||||
console.warn(this.localName, 'connected (user)', this.shadowRoot);
|
||||
console.groupEnd(this.localName, 'connected');
|
||||
}
|
||||
_flushProperties() {
|
||||
console.log('flush', this.localName);
|
||||
console.log(this.localName, 'flush');
|
||||
super._flushProperties();
|
||||
}
|
||||
ready() {
|
||||
console.group('ready', this.localName);
|
||||
console.group(this.localName, 'ready');
|
||||
this.dispatchEvent(new CustomEvent('child-is-here', {bubbles: true, composed: true}));
|
||||
super.ready();
|
||||
console.warn('ready (user)', this.localName, this.shadowRoot);
|
||||
console.groupEnd('ready', this.localName);
|
||||
console.warn(this.localName, 'ready (user)', this.shadowRoot);
|
||||
console.log(this.localName, 'childList', this.childList);
|
||||
console.groupEnd(this.localName, 'ready');
|
||||
}
|
||||
}
|
||||
customElements.define('x-b', XB);
|
||||
@@ -78,27 +95,29 @@
|
||||
}
|
||||
static get observers() { return ['propChanged(prop)']}
|
||||
propChanged() {
|
||||
console.log('propChanged', this.localName, this.shadowRoot);
|
||||
console.log(this.localName, 'propChanged', this.shadowRoot);
|
||||
}
|
||||
constructor() {
|
||||
console.log('constructed', 'x-c');
|
||||
console.log('x-c', 'constructed');
|
||||
super();
|
||||
this.childList = [];
|
||||
}
|
||||
connectedCallback() {
|
||||
console.group('connected', this.localName);
|
||||
console.group(this.localName, 'connected');
|
||||
super.connectedCallback();
|
||||
console.warn('connected (user)', this.localName, this.shadowRoot);
|
||||
console.groupEnd('connected', this.localName);
|
||||
console.warn(this.localName, 'connected (user)', this.shadowRoot);
|
||||
console.groupEnd(this.localName, 'connected');
|
||||
}
|
||||
_flushProperties() {
|
||||
console.log('flush', this.localName);
|
||||
console.log(this.localName, 'flush');
|
||||
super._flushProperties();
|
||||
}
|
||||
ready() {
|
||||
console.group('ready', this.localName);
|
||||
console.group(this.localName, 'ready');
|
||||
this.dispatchEvent(new CustomEvent('child-is-here', {bubbles: true, composed: true}));
|
||||
super.ready();
|
||||
console.warn('ready (user)', this.localName, this.shadowRoot);
|
||||
console.groupEnd('ready', this.localName);
|
||||
console.warn(this.localName, 'ready (user)', this.shadowRoot);
|
||||
console.groupEnd(this.localName, 'ready');
|
||||
}
|
||||
}
|
||||
customElements.define('x-c', XC);
|
||||
|
||||
@@ -13,6 +13,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<meta charset="UTF-8">
|
||||
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../../web-component-tester/browser.js"></script>
|
||||
<script>
|
||||
Polymer = {
|
||||
rootPath: 'earlyRootPath/'
|
||||
}
|
||||
</script>
|
||||
<link rel="import" href="../../polymer.html">
|
||||
<link id="elements" rel="import" href="sub/resolveurl-elements.html">
|
||||
</head>
|
||||
@@ -82,6 +87,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
document.body.removeChild(el);
|
||||
});
|
||||
|
||||
test('rootPath set early', function() {
|
||||
class XEarly extends Polymer.Element {
|
||||
static get is() { return 'x-late'}
|
||||
}
|
||||
customElements.define('x-early', XEarly);
|
||||
var el = document.createElement('x-early');
|
||||
document.body.appendChild(el);
|
||||
var matchRoot = /earlyRootPath\//i;
|
||||
assert.match(el.$.root.getAttribute('src'), matchRoot);
|
||||
document.body.removeChild(el);
|
||||
});
|
||||
|
||||
test('url changes via setting importPath/rootPath when defining element', function() {
|
||||
Polymer.rootPath = 'defineRoot/';
|
||||
class XLate extends Polymer.Element {
|
||||
|
||||
Reference in New Issue
Block a user