2016-08-11 18:07:41 -07:00
|
|
|
<!--
|
|
|
|
|
@license
|
|
|
|
|
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
|
|
|
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
|
|
|
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
|
|
|
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
|
|
|
Code distributed by Google as part of the polymer project is also
|
|
|
|
|
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
|
|
|
-->
|
|
|
|
|
|
2017-02-17 19:18:07 -08:00
|
|
|
<link rel="import" href="../utils/boot.html">
|
|
|
|
|
<link rel="import" href="../utils/mixin.html">
|
|
|
|
|
<link rel="import" href="../utils/case-map.html">
|
|
|
|
|
<link rel="import" href="../utils/style-gather.html">
|
|
|
|
|
<link rel="import" href="../utils/resolve-url.html">
|
2017-02-14 10:25:44 -08:00
|
|
|
<link rel="import" href="../elements/dom-module.html">
|
|
|
|
|
<link rel="import" href="property-effects.html">
|
2016-08-11 18:07:41 -07:00
|
|
|
|
|
|
|
|
<script>
|
2017-02-27 16:06:41 -08:00
|
|
|
(function() {
|
2017-03-03 16:03:45 -08:00
|
|
|
'use strict';
|
2017-02-15 20:16:03 -08:00
|
|
|
/**
|
2017-02-27 16:06:41 -08:00
|
|
|
* @typedef Object<string, {
|
|
|
|
|
* value: *,
|
|
|
|
|
* type: (Function | undefined),
|
|
|
|
|
* readOnly: (boolean | undefined),
|
|
|
|
|
* computed: (string | undefined),
|
|
|
|
|
* reflectToAttribute: (boolean | undefined),
|
|
|
|
|
* notify: (boolean | undefined),
|
|
|
|
|
* observer: (string | undefined)
|
|
|
|
|
* }>)
|
2017-02-15 20:16:03 -08:00
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
let PolymerElementProperties; // eslint-disable-line no-unused-vars
|
|
|
|
|
|
|
|
|
|
/** @record */
|
|
|
|
|
let PolymerElementConstructor = function(){}; // eslint-disable-line no-unused-vars
|
|
|
|
|
/** @type {(string | undefined)} */
|
|
|
|
|
PolymerElementConstructor.is;
|
|
|
|
|
/** @type {(string | undefined)} */
|
|
|
|
|
PolymerElementConstructor.extends;
|
|
|
|
|
/** @type {(!PolymerElementProperties | undefined)} */
|
|
|
|
|
PolymerElementConstructor.properties;
|
|
|
|
|
/** @type {(!Array<string> | undefined)} */
|
|
|
|
|
PolymerElementConstructor.observers;
|
|
|
|
|
/** @type {(!HTMLTemplateElement | string | undefined)} */
|
|
|
|
|
PolymerElementConstructor.template;
|
2017-02-23 19:39:53 -08:00
|
|
|
|
|
|
|
|
/**
|
2017-02-27 16:06:41 -08:00
|
|
|
* Element class mixin that provides the core API for Polymer's meta-programming
|
|
|
|
|
* features including template stamping, data-binding, attribute deserialization,
|
|
|
|
|
* and property change observation.
|
|
|
|
|
*
|
2017-02-28 16:19:24 -08:00
|
|
|
* Subclassers may provide the following static getters to return metadata
|
|
|
|
|
* used to configure Polymer's features for the class:
|
|
|
|
|
*
|
|
|
|
|
* - `static get is()`: When the template is provided via a `dom-module`,
|
|
|
|
|
* users should return the `dom-module` id from a static `is` getter. If
|
|
|
|
|
* no template is needed or the template is provided directly via the
|
|
|
|
|
* `template` getter, there is no need to define `is` for the element.
|
|
|
|
|
*
|
|
|
|
|
* - `static get template()`: Users may provide the template directly (as
|
|
|
|
|
* opposed to via `dom-module`) by implementing a static `template` getter.
|
|
|
|
|
* The getter may return an `HTMLTemplateElement` or a string, which will
|
|
|
|
|
* automatically be parsed into a template.
|
|
|
|
|
*
|
|
|
|
|
* - `static get properties()`: Should return an object describing
|
|
|
|
|
* property-related metadata used by Polymer features (key: property name
|
|
|
|
|
* value: object containing property metadata). Valid keys in per-property
|
|
|
|
|
* metadata include:
|
|
|
|
|
* - `type` (String|Number|Object|Array|...): Used by
|
|
|
|
|
* `attributeChangedCallback` to determine how string-based attributes
|
|
|
|
|
* are deserialized to JavaScript property values.
|
|
|
|
|
* - `notify` (boolean): Causes a change in the property to fire a
|
|
|
|
|
* non-bubbling event called `<property>-changed`. Elements that have
|
|
|
|
|
* enabled two-way binding to the property use this event to observe changes.
|
|
|
|
|
* - `readOnly` (boolean): Creates a getter for the property, but no setter.
|
|
|
|
|
* To set a read-only property, use the private setter method
|
|
|
|
|
* `_setProperty(property, value)`.
|
|
|
|
|
* - `observer` (string): Observer method name that will be called when
|
|
|
|
|
* the property changes. The arguments of the method are
|
|
|
|
|
* `(value, previousValue)`.
|
|
|
|
|
* - `computed` (string): String describing method and dependent properties
|
|
|
|
|
* for computing the value of this property (e.g. `'computeFoo(bar, zot)'`).
|
|
|
|
|
* Computed properties are read-only by default and can only be changed
|
|
|
|
|
* via the return value of the computing method.
|
|
|
|
|
*
|
|
|
|
|
* - `static get observers()`: Array of strings describing multi-property
|
|
|
|
|
* observer methods and their dependent properties (e.g.
|
|
|
|
|
* `'observeABC(a, b, c)'`).
|
|
|
|
|
*
|
|
|
|
|
* The base class provides default implementations for the following standard
|
|
|
|
|
* custom element lifecycle callbacks; users may override these, but should
|
|
|
|
|
* call the super method to ensure
|
|
|
|
|
* - `constructor`: Run when the element is created or upgraded
|
|
|
|
|
* - `connectedCallback`: Run each time the element is connected to the
|
|
|
|
|
* document
|
|
|
|
|
* - `disconnectedCallback`: Run each time the element is disconnected from
|
|
|
|
|
* the document
|
|
|
|
|
* - `attributeChangedCallback`: Run each time an attribute in
|
|
|
|
|
* `observedAttributes` is set or removed (note: this element's default
|
|
|
|
|
* `observedAttributes` implementation will automatically return an array
|
|
|
|
|
* of dash-cased attributes based on `properties`)
|
|
|
|
|
*
|
2017-02-27 16:06:41 -08:00
|
|
|
* @polymerMixin
|
|
|
|
|
* @mixes Polymer.PropertyEffects
|
|
|
|
|
* @memberof Polymer
|
2017-03-03 11:21:26 -08:00
|
|
|
* @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.
|
2017-02-28 03:17:30 -08:00
|
|
|
* @summary Element class mixin that provides the core API for Polymer's
|
|
|
|
|
* meta-programming features.
|
2017-02-23 19:39:53 -08:00
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
Polymer.ElementMixin = Polymer.dedupingMixin(function(base) {
|
2017-02-15 20:16:03 -08:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
const polymerElementBase = Polymer.PropertyEffects(base);
|
|
|
|
|
|
|
|
|
|
let caseMap = Polymer.CaseMap;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the `properties` object specifically on `klass`. Use for:
|
|
|
|
|
* (1) super chain mixes togther to make `propertiesForClass` which is
|
|
|
|
|
* then used to make `observedAttributes`.
|
|
|
|
|
* (2) properties effects and observers are created from it at `finalize` time.
|
|
|
|
|
* @param {HTMLElement} klass
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function ownPropertiesForClass(klass) {
|
|
|
|
|
if (!klass.hasOwnProperty(
|
|
|
|
|
goog.reflect.objectProperty('__ownProperties', klass))) {
|
|
|
|
|
klass.__ownProperties =
|
|
|
|
|
klass.hasOwnProperty(goog.reflect.objectProperty('properties', klass)) ?
|
|
|
|
|
klass.properties : {};
|
2016-10-21 12:18:32 -07:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
return klass.__ownProperties;
|
2016-10-21 12:18:32 -07:00
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Returns the `observers` array specifically on `klass`. Use for
|
|
|
|
|
* setting up observers.
|
|
|
|
|
* @param {HTMLElement} klass
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function ownObserversForClass(klass) {
|
|
|
|
|
if (!klass.hasOwnProperty(
|
|
|
|
|
goog.reflect.objectProperty('__ownObservers', klass))) {
|
|
|
|
|
klass.__ownObservers =
|
|
|
|
|
klass.hasOwnProperty(goog.reflect.objectProperty('observers', klass)) ?
|
|
|
|
|
klass.observers : [];
|
2016-08-11 18:07:41 -07:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
return klass.__ownObservers;
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2016-08-11 18:07:41 -07:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Mixes `props` into `flattenedProps` but upgrades shorthand type
|
|
|
|
|
* syntax to { type: Type}.
|
|
|
|
|
* @param {Object} flattenedProps
|
|
|
|
|
* @param {Object} props
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function flattenProperties(flattenedProps, props) {
|
2017-02-15 20:16:03 -08:00
|
|
|
for (let p in props) {
|
2017-02-27 16:06:41 -08:00
|
|
|
let o = props[p];
|
|
|
|
|
if (typeof o == 'function') {
|
|
|
|
|
o = { type: o };
|
2016-08-11 18:07:41 -07:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
flattenedProps[p] = o;
|
2016-08-11 18:07:41 -07:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
return flattenedProps;
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2016-08-11 18:07:41 -07:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Returns a flattened list of properties mixed together from the chain of all
|
|
|
|
|
* constructor's `config.properties`. This list is used to create
|
|
|
|
|
* (1) observedAttributes,
|
|
|
|
|
* (2) class property default values
|
|
|
|
|
* @param {HTMLElement} klass
|
|
|
|
|
* @return {PolymerElementProperties}
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function propertiesForClass(klass) {
|
|
|
|
|
if (!klass.hasOwnProperty(
|
|
|
|
|
goog.reflect.objectProperty('__classProperties', klass))) {
|
|
|
|
|
klass.__classProperties =
|
|
|
|
|
flattenProperties({}, ownPropertiesForClass(klass));
|
|
|
|
|
let superCtor = Object.getPrototypeOf(klass.prototype).constructor;
|
|
|
|
|
if (superCtor.prototype instanceof PolymerElement) {
|
2017-03-03 14:14:00 -08:00
|
|
|
klass.__classProperties = Object.assign(
|
2017-02-27 16:06:41 -08:00
|
|
|
Object.create(propertiesForClass(superCtor)),
|
|
|
|
|
klass.__classProperties);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return klass.__classProperties;
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2017-01-17 11:28:35 -08:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Returns a list of properties with default values.
|
|
|
|
|
* This list is created as an optimization since it is a subset of
|
|
|
|
|
* the list returned from `propertiesForClass`.
|
|
|
|
|
* This list is used in `_initializeProperties` to set property defaults.
|
|
|
|
|
* @param {HTMLElement} klass
|
|
|
|
|
* @return {PolymerElementProperties}
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function propertyDefaultsForClass(klass) {
|
|
|
|
|
if (!klass.hasOwnProperty(
|
|
|
|
|
goog.reflect.objectProperty('__classPropertyDefaults', klass))) {
|
2017-03-03 15:59:22 -08:00
|
|
|
klass.__classPropertyDefaults = null;
|
2017-02-27 16:06:41 -08:00
|
|
|
let props = propertiesForClass(klass);
|
|
|
|
|
for (let p in props) {
|
|
|
|
|
let info = props[p];
|
|
|
|
|
if ('value' in info) {
|
|
|
|
|
klass.__classPropertyDefaults = klass.__classPropertyDefaults || {};
|
|
|
|
|
klass.__classPropertyDefaults[p] = info;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-24 13:17:25 -08:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
return klass.__classPropertyDefaults;
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2017-01-17 11:28:35 -08:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Returns true if a `klass` has finalized. Called in `ElementClass.finalize()`
|
|
|
|
|
* @param {HTMLElement} klass
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function hasClassFinalized(klass) {
|
|
|
|
|
return klass.hasOwnProperty(goog.reflect.objectProperty('__finalized', klass));
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2017-02-23 19:39:53 -08:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Called by `ElementClass.finalize()`. Ensures this `klass` and
|
|
|
|
|
* *all superclasses* are finalized by traversing the prototype chain
|
|
|
|
|
* and calling `klass.finalize()`.
|
|
|
|
|
* @param {HTMLElement} klass
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function finalizeClassAndSuper(klass) {
|
|
|
|
|
let proto = klass.prototype;
|
|
|
|
|
let superCtor = Object.getPrototypeOf(proto).constructor;
|
|
|
|
|
if (superCtor.prototype instanceof PolymerElement) {
|
|
|
|
|
superCtor.finalize();
|
|
|
|
|
}
|
|
|
|
|
finalizeClass(klass);
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2016-08-11 18:07:41 -07:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Configures a `klass` based on a staic `klass.config` object and
|
|
|
|
|
* a `template`. This includes creating accessors and effects
|
|
|
|
|
* for properties in `config` and the `template` as well as preparing the
|
|
|
|
|
* `template` for stamping.
|
|
|
|
|
*/
|
|
|
|
|
function finalizeClass(klass) {
|
|
|
|
|
klass.__finalized = true;
|
|
|
|
|
let proto = klass.prototype;
|
|
|
|
|
if (klass.hasOwnProperty(
|
|
|
|
|
goog.reflect.objectProperty('is', klass)) && klass.is) {
|
|
|
|
|
Polymer.telemetry.register(proto);
|
|
|
|
|
}
|
|
|
|
|
let props = ownPropertiesForClass(klass);
|
|
|
|
|
if (props) {
|
|
|
|
|
finalizeProperties(proto, props);
|
|
|
|
|
}
|
|
|
|
|
let observers = ownObserversForClass(klass);
|
|
|
|
|
if (observers) {
|
|
|
|
|
finalizeObservers(proto, observers, props);
|
|
|
|
|
}
|
|
|
|
|
// note: create "working" template that is finalized at instance time
|
|
|
|
|
let template = klass.template;
|
|
|
|
|
if (template) {
|
|
|
|
|
if (typeof template === 'string') {
|
|
|
|
|
let t = document.createElement('template');
|
|
|
|
|
t.innerHTML = template;
|
|
|
|
|
template = t;
|
|
|
|
|
} else {
|
|
|
|
|
template = template.cloneNode(true);
|
|
|
|
|
}
|
|
|
|
|
proto._template = template;
|
|
|
|
|
}
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2016-08-11 18:07:41 -07:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Configures a `proto` based on a `properties` object.
|
|
|
|
|
* Leverages `PropertyEffects` to create property accessors and effects
|
|
|
|
|
* supporting, observers, reflecting to attributes, change notification,
|
|
|
|
|
* computed properties, and read only properties.
|
|
|
|
|
* @param {HTMLElement} proto
|
|
|
|
|
* @param {Object} properties
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function finalizeProperties(proto, properties) {
|
|
|
|
|
for (let p in properties) {
|
|
|
|
|
createPropertyFromConfig(proto, p, properties[p], properties);
|
|
|
|
|
}
|
2017-02-16 12:24:03 -08:00
|
|
|
}
|
2016-08-11 18:07:41 -07:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Configures a `proto` based on a `observers` array.
|
|
|
|
|
* Leverages `PropertyEffects` to create observers.
|
|
|
|
|
* @param {HTMLElement} proto
|
|
|
|
|
* @param {Array} observers
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function finalizeObservers(proto, observers, dynamicProperties) {
|
|
|
|
|
for (let i=0; i < observers.length; i++) {
|
|
|
|
|
proto._createMethodObserver(observers[i], dynamicProperties);
|
2016-08-22 18:52:55 -07:00
|
|
|
}
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2016-08-22 18:52:55 -07:00
|
|
|
|
2017-02-15 20:16:03 -08:00
|
|
|
/**
|
2017-02-27 16:06:41 -08:00
|
|
|
* Creates effects for a property.
|
|
|
|
|
*
|
|
|
|
|
* Note, once a property has been set to
|
|
|
|
|
* `readOnly`, `computed`, `reflectToAttribute`, or `notify`
|
|
|
|
|
* these values may not be changed. For example, a subclass cannot
|
|
|
|
|
* alter these settings. However, additional `observers` may be added
|
|
|
|
|
* by subclasses.
|
|
|
|
|
*
|
2017-02-28 16:19:24 -08:00
|
|
|
* The info object should may contain property metadata as follows:
|
2017-02-27 16:06:41 -08:00
|
|
|
*
|
2017-02-28 16:19:24 -08:00
|
|
|
* * `type`: {function} type to which an attribute matching the property
|
2017-02-27 16:06:41 -08:00
|
|
|
* is deserialized. Note the property is camel-cased from a dash-cased
|
|
|
|
|
* attribute. For example, 'foo-bar' attribute is dersialized to a
|
|
|
|
|
* property named 'fooBar'.
|
|
|
|
|
*
|
2017-02-28 16:19:24 -08:00
|
|
|
* * `readOnly`: {boolean} creates a readOnly property and
|
2017-02-27 16:06:41 -08:00
|
|
|
* makes a private setter for the private of the form '_setFoo' for a
|
|
|
|
|
* property 'foo',
|
|
|
|
|
*
|
2017-02-28 16:19:24 -08:00
|
|
|
* * `computed`: {string} creates a computed property. A computed property
|
2017-02-27 16:06:41 -08:00
|
|
|
* also automatically is set to `readOnly: true`. The value is calculated
|
|
|
|
|
* by running a method and arguments parsed from the given string. For
|
|
|
|
|
* example 'compute(foo)' will compute a given property when the
|
|
|
|
|
* 'foo' property changes by executing the 'compute' method. This method
|
|
|
|
|
* must return the computed value.
|
|
|
|
|
*
|
2017-02-28 16:19:24 -08:00
|
|
|
* * `reflectToAttriute`: {boolean} If true, the property value is reflected
|
2017-02-27 16:06:41 -08:00
|
|
|
* to an attribute of the same name. Note, the attribute is dash-cased
|
|
|
|
|
* so a property named 'fooBar' is reflected as 'foo-bar'.
|
|
|
|
|
*
|
2017-02-28 16:19:24 -08:00
|
|
|
* * `notify`: {boolean} sends a non-bubbling notification event when
|
2017-02-27 16:06:41 -08:00
|
|
|
* the property changes. For example, a property named 'foo' sends an
|
|
|
|
|
* event named 'foo-changed' with `event.detail` set to the value of
|
|
|
|
|
* the property.
|
|
|
|
|
*
|
|
|
|
|
* * observer: {string} name of a method that runs when the property
|
|
|
|
|
* changes. The arguments of the method are (value, previousValue).
|
|
|
|
|
*
|
2017-02-28 16:19:24 -08:00
|
|
|
* Note: Users may want control over modifying property
|
|
|
|
|
* effects via subclassing. For example, a user might want to make a
|
|
|
|
|
* reflectToAttribute property not do so in a subclass. We've chosen to
|
|
|
|
|
* disable this because it leads to additional complication.
|
|
|
|
|
* For example, a readOnly effect generates a special setter. If a subclass
|
|
|
|
|
* disables the effect, the setter would fail unexpectedly.
|
|
|
|
|
* Based on feedback, we may want to try to make effects more malleable
|
|
|
|
|
* and/or provide an advanced api for manipulating them.
|
|
|
|
|
* Also consider adding warnings when an effect cannot be changed.
|
|
|
|
|
*
|
2017-02-27 16:06:41 -08:00
|
|
|
* @param {HTMLElement} proto
|
2017-02-28 16:19:24 -08:00
|
|
|
* @param {string} name Name of the property.
|
|
|
|
|
* @param {object} info Info object from which to create property effects.
|
|
|
|
|
* Supported keys:
|
|
|
|
|
* @param {object} allProps Flattened map of all properties defined in this
|
|
|
|
|
* element (including inherited properties)
|
2017-02-27 16:06:41 -08:00
|
|
|
* @private
|
2017-02-15 20:16:03 -08:00
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
function createPropertyFromConfig(proto, name, info, allProps) {
|
|
|
|
|
// computed forces readOnly...
|
|
|
|
|
if (info.computed) {
|
|
|
|
|
info.readOnly = true;
|
|
|
|
|
}
|
|
|
|
|
// Note, since all computed properties are readOnly, this prevents
|
|
|
|
|
// adding additional computed property effects (which leads to a confusing
|
|
|
|
|
// setup where multiple triggers for setting a property)
|
|
|
|
|
// While we do have `hasComputedEffect` this is set on the property's
|
|
|
|
|
// dependencies rather than itself.
|
|
|
|
|
if (info.computed && !proto._hasReadOnlyEffect(name)) {
|
|
|
|
|
proto._createComputedProperty(name, info.computed, allProps);
|
|
|
|
|
}
|
|
|
|
|
if (info.readOnly && !proto._hasReadOnlyEffect(name)) {
|
|
|
|
|
proto._createReadOnlyProperty(name, !info.computed);
|
|
|
|
|
}
|
|
|
|
|
if (info.reflectToAttribute && !proto._hasReflectEffect(name)) {
|
|
|
|
|
proto._createReflectedProperty(name);
|
|
|
|
|
}
|
|
|
|
|
if (info.notify && !proto._hasNotifyEffect(name)) {
|
|
|
|
|
proto._createNotifyingProperty(name);
|
|
|
|
|
}
|
|
|
|
|
// always add observer
|
|
|
|
|
if (info.observer) {
|
|
|
|
|
proto._createPropertyObserver(name, info.observer, allProps[info.observer]);
|
2016-08-15 09:38:20 -07:00
|
|
|
}
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2016-08-15 09:38:20 -07:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Configures an element `proto` to function with a given `template`.
|
|
|
|
|
* The element name `is` and extends `ext` must be specified for ShadyCSS
|
|
|
|
|
* style scoping.
|
|
|
|
|
* @param {HTMLElement} proto
|
|
|
|
|
* @param {HTMLTemplateElement} template
|
2017-03-01 19:37:17 -08:00
|
|
|
* @param {string} baseURI URL against which to resolve urls in
|
|
|
|
|
* style element cssText.
|
2017-02-27 16:06:41 -08:00
|
|
|
* @param {string} is
|
|
|
|
|
* @param {string} ext
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
2017-03-01 19:37:17 -08:00
|
|
|
function finalizeTemplate(proto, template, baseURI, is, ext) {
|
2017-02-27 16:06:41 -08:00
|
|
|
// support `include="module-name"`
|
2017-03-01 19:37:17 -08:00
|
|
|
let cssText =
|
|
|
|
|
Polymer.StyleGather.cssFromTemplate(template, baseURI) +
|
2017-02-27 16:06:41 -08:00
|
|
|
Polymer.StyleGather.cssFromModuleImports(is);
|
|
|
|
|
if (cssText) {
|
|
|
|
|
let style = document.createElement('style');
|
|
|
|
|
style.textContent = cssText;
|
|
|
|
|
template.content.insertBefore(style, template.content.firstChild);
|
2016-09-02 16:05:16 -07:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
if (window.ShadyCSS) {
|
|
|
|
|
window.ShadyCSS.prepareTemplate(template, is, ext);
|
|
|
|
|
}
|
|
|
|
|
proto._bindTemplate(template, propertiesForClass(proto.constructor));
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2016-09-02 16:05:16 -07:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* @polymerMixinClass
|
|
|
|
|
* @unrestricted
|
|
|
|
|
*/
|
|
|
|
|
class PolymerElement extends polymerElementBase {
|
|
|
|
|
|
2017-02-28 16:19:24 -08:00
|
|
|
/**
|
|
|
|
|
* Standard Custom Elements V1 API. The default implementation returns
|
|
|
|
|
* a list of dash-cased attributes based on a flattening of all properties
|
|
|
|
|
* declared in `static get properties()` for this element and any
|
|
|
|
|
* superclasses.
|
|
|
|
|
*
|
|
|
|
|
* @return {Array} Observed attribute list
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
static get observedAttributes() {
|
|
|
|
|
if (!this.hasOwnProperty(goog.reflect.objectProperty('__observedAttributes', this))) {
|
|
|
|
|
let list = [];
|
|
|
|
|
let properties = propertiesForClass(this);
|
|
|
|
|
for (let prop in properties) {
|
|
|
|
|
list.push(Polymer.CaseMap.camelToDashCase(prop));
|
|
|
|
|
}
|
|
|
|
|
this.__observedAttributes = list;
|
|
|
|
|
}
|
|
|
|
|
return this.__observedAttributes;
|
2017-02-23 13:10:53 -08:00
|
|
|
}
|
2016-09-19 19:21:54 -07:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
|
|
|
|
* Called automatically when the first element instance is created to
|
|
|
|
|
* ensure that class finalization work has been completed.
|
|
|
|
|
* May be called by users to eagerly perform class finalization work
|
|
|
|
|
* prior to the creation of the first element instance.
|
2017-02-28 16:19:24 -08:00
|
|
|
*
|
|
|
|
|
* Class finalization work generally includes meta-programming such as
|
|
|
|
|
* creating property accessors and any property effect metadata needed for
|
|
|
|
|
* the features used.
|
|
|
|
|
*
|
2017-02-27 16:06:41 -08:00
|
|
|
* @public
|
|
|
|
|
*/
|
|
|
|
|
static finalize() {
|
|
|
|
|
if (!hasClassFinalized(this)) {
|
|
|
|
|
finalizeClassAndSuper(this);
|
|
|
|
|
}
|
2017-02-24 13:17:25 -08:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
|
2017-02-28 16:19:24 -08:00
|
|
|
/**
|
|
|
|
|
* Returns the template stamped into this element's shadow root.
|
|
|
|
|
*
|
|
|
|
|
* If a `static get is()` getter is defined, the default implementation
|
|
|
|
|
* will return the first `<template>` in a `dom-module` whose `id`
|
|
|
|
|
* matches this element's `is`.
|
|
|
|
|
*
|
|
|
|
|
* Users may override this getter to return an arbitrary template
|
|
|
|
|
* (in which case the `is` getter is unnecessary). The template returned
|
|
|
|
|
* may be either an `HTMLTemplateElement` or a string that will be
|
|
|
|
|
* automatically parsed into a template.
|
|
|
|
|
*
|
|
|
|
|
* Note that when subclassing, if the super class overrode the default
|
|
|
|
|
* implementation and the subclass would like to provide an alternate
|
|
|
|
|
* template via a `dom-module`, it should override this getter and
|
|
|
|
|
* return `Polymer.DomModule.import(this.is, 'template')`.
|
|
|
|
|
*
|
|
|
|
|
* If a subclass would like to modify the super class template, it should
|
|
|
|
|
* clone it rather than modify it in place. If the getter does expensive
|
|
|
|
|
* work such as cloning/modifying a template, it should memoize the
|
|
|
|
|
* template for maximum performance:
|
|
|
|
|
*
|
|
|
|
|
* let memoizedTemplate;
|
|
|
|
|
* class MySubClass extends MySuperClass {
|
|
|
|
|
* static get template() {
|
|
|
|
|
* if (!memoizedTemplate) {
|
|
|
|
|
* memoizedTemplate = super.template.cloneNode(true);
|
|
|
|
|
* let subContent = document.createElement('div');
|
|
|
|
|
* subContent.textContent = 'This came from MySubClass';
|
2017-03-02 02:37:22 -08:00
|
|
|
* memoizedTemplate.content.appendChild(subContent);
|
2017-02-28 16:19:24 -08:00
|
|
|
* }
|
|
|
|
|
* return memoizedTemplate;
|
|
|
|
|
* }
|
|
|
|
|
* }
|
2017-03-02 17:38:43 -08:00
|
|
|
*
|
|
|
|
|
* @returns {HTMLTemplateElement|string}
|
2017-02-28 16:19:24 -08:00
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
static get template() {
|
|
|
|
|
if (!this.hasOwnProperty(goog.reflect.objectProperty('_template', this))) {
|
|
|
|
|
this._template = Polymer.DomModule.import(this.is, 'template') ||
|
|
|
|
|
// note: implemented so a subclass can retrieve the super
|
|
|
|
|
// template; call the super impl this way so that `this` points
|
|
|
|
|
// to the superclass.
|
|
|
|
|
Object.getPrototypeOf(this.prototype).constructor.template;
|
|
|
|
|
}
|
|
|
|
|
return this._template;
|
2016-08-11 18:07:41 -07:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
|
2017-03-01 19:37:17 -08:00
|
|
|
/**
|
|
|
|
|
* Path matching the url from which the element was imported.
|
|
|
|
|
* This path is used to resolve url's in template style cssText.
|
|
|
|
|
* The `importPath` property is also set on element instances and can be
|
|
|
|
|
* used to create bindings relative to the import path.
|
|
|
|
|
* Defaults to the path matching the url containing a `dom-module` element
|
|
|
|
|
* matching this element's static `is` property.
|
2017-03-02 17:38:43 -08:00
|
|
|
* Note, this path should contain a trailing `/`.
|
|
|
|
|
*
|
|
|
|
|
* @returns {string}
|
2017-03-01 19:37:17 -08:00
|
|
|
*/
|
|
|
|
|
static get importPath() {
|
|
|
|
|
if (!this.hasOwnProperty(goog.reflect.objectProperty('_importPath', this))) {
|
|
|
|
|
const module = Polymer.DomModule.import(this.is);
|
|
|
|
|
this._importPath = module ? module.assetpath : '' ||
|
|
|
|
|
Object.getPrototypeOf(this.prototype).constructor.importPath;
|
|
|
|
|
}
|
|
|
|
|
return this._importPath;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
Polymer.telemetry.instanceCount++;
|
|
|
|
|
// Stamp template
|
|
|
|
|
if (this._template) {
|
|
|
|
|
this.root = this._stampTemplate(this._template);
|
|
|
|
|
} else {
|
|
|
|
|
this.root = this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 16:19:24 -08:00
|
|
|
/**
|
|
|
|
|
* Overrides the default `Polymer.PropertyAccessors` to ensure class
|
2017-02-28 17:07:32 -08:00
|
|
|
* metaprogramming related to property accessors and effects has
|
|
|
|
|
* completed (calls `finalize`).
|
2017-02-28 16:19:24 -08:00
|
|
|
*
|
2017-02-28 17:07:32 -08:00
|
|
|
* It also initializes any property defaults provided via `value` in
|
|
|
|
|
* `properties` metadata.
|
2017-02-28 16:19:24 -08:00
|
|
|
*
|
|
|
|
|
* @override
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
_initializeProperties() {
|
|
|
|
|
this.constructor.finalize();
|
2017-03-01 19:37:17 -08:00
|
|
|
const importPath = this.constructor.importPath;
|
2017-02-27 16:06:41 -08:00
|
|
|
// note: finalize template when we have access to `localName` to
|
|
|
|
|
// avoid dependence on `is` for polyfilling styling.
|
|
|
|
|
if (this._template && !this._template.__polymerFinalized) {
|
|
|
|
|
this._template.__polymerFinalized = true;
|
2017-03-02 17:38:43 -08:00
|
|
|
const baseURI =
|
|
|
|
|
importPath ? Polymer.ResolveUrl.resolveUrl(importPath) : '';
|
|
|
|
|
finalizeTemplate(this.__proto__, this._template, baseURI,
|
2017-03-01 19:37:17 -08:00
|
|
|
this.localName);
|
2017-02-27 16:06:41 -08:00
|
|
|
}
|
|
|
|
|
super._initializeProperties();
|
2017-03-01 19:37:17 -08:00
|
|
|
// set path defaults
|
|
|
|
|
this.rootPath = Polymer.rootPath;
|
|
|
|
|
this.importPath = importPath;
|
2017-02-27 16:06:41 -08:00
|
|
|
// apply property defaults...
|
|
|
|
|
let p$ = propertyDefaultsForClass(this.constructor);
|
|
|
|
|
if (!p$) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (let p in p$) {
|
|
|
|
|
let info = p$[p];
|
|
|
|
|
if (!this._isPropertyPending(p)) {
|
2017-03-03 15:58:52 -08:00
|
|
|
let value = typeof info.value == 'function' ?
|
2017-02-27 16:06:41 -08:00
|
|
|
info.value.call(this) :
|
|
|
|
|
info.value;
|
|
|
|
|
if (this._hasPropertyEffect(p)) {
|
|
|
|
|
this._setProperty(p, value)
|
|
|
|
|
} else {
|
|
|
|
|
this[p] = value;
|
|
|
|
|
}
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2016-08-11 18:07:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
|
|
|
|
* Provides a default implementation of the standard Custom Elements
|
|
|
|
|
* `connectedCallback`.
|
|
|
|
|
*
|
|
|
|
|
* The default implementation enables the property effects system and
|
|
|
|
|
* flushes any pending properties, and updates shimmed CSS properties
|
|
|
|
|
* when using the ShadyCSS scoping/custom properties polyfill.
|
|
|
|
|
*
|
|
|
|
|
* @override
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
connectedCallback() {
|
|
|
|
|
if (window.ShadyCSS) {
|
|
|
|
|
window.ShadyCSS.styleElement(this);
|
|
|
|
|
}
|
|
|
|
|
this._flushProperties();
|
2017-02-16 12:24:03 -08:00
|
|
|
}
|
2016-09-12 18:26:08 -07:00
|
|
|
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
|
|
|
|
* Provides a default implementation of the standard Custom Elements
|
|
|
|
|
* `disconnectedCallback`.
|
|
|
|
|
*
|
|
|
|
|
* @override
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
disconnectedCallback() {}
|
2017-02-15 20:16:03 -08:00
|
|
|
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
2017-02-28 19:46:35 -08:00
|
|
|
* Implements `PropertyEffects`'s `_readyClients` call. Attaches
|
|
|
|
|
* element dom by calling `_attachDom` with the dom stamped from the
|
|
|
|
|
* element's template via `_stampTemplate`. Note that this allows
|
|
|
|
|
* client dom to be attached to the element prior to any observers
|
|
|
|
|
* running.
|
2017-02-28 17:07:32 -08:00
|
|
|
*
|
|
|
|
|
* @override
|
|
|
|
|
*/
|
2017-02-28 19:46:35 -08:00
|
|
|
_readyClients() {
|
|
|
|
|
super._readyClients();
|
2017-02-27 16:06:41 -08:00
|
|
|
if (this._template) {
|
|
|
|
|
this.root = this._attachDom(this.root);
|
|
|
|
|
}
|
2016-08-11 18:07:41 -07:00
|
|
|
}
|
|
|
|
|
|
2017-02-28 19:46:35 -08:00
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
2017-02-28 17:07:32 -08:00
|
|
|
* Attaches an element's stamped dom to itself. By default,
|
2017-02-27 16:06:41 -08:00
|
|
|
* this method creates a `shadowRoot` and adds the dom to it.
|
|
|
|
|
* However, this method may be overridden to allow an element
|
|
|
|
|
* to put its dom in another location.
|
|
|
|
|
*
|
|
|
|
|
* @method _attachDom
|
|
|
|
|
* @throws {Error}
|
|
|
|
|
* @suppress {missingReturn}
|
|
|
|
|
* @param {NodeList} dom to attach to the element.
|
|
|
|
|
* @return {Node} node to which the dom has been attached.
|
|
|
|
|
*/
|
|
|
|
|
_attachDom(dom) {
|
|
|
|
|
if (this.attachShadow) {
|
|
|
|
|
if (dom) {
|
|
|
|
|
if (!this.shadowRoot) {
|
|
|
|
|
this.attachShadow({mode: 'open'});
|
|
|
|
|
}
|
|
|
|
|
this.shadowRoot.appendChild(dom);
|
|
|
|
|
return this.shadowRoot;
|
2016-12-06 11:03:50 -08:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
} else {
|
|
|
|
|
throw new Error('ShadowDOM not available. ' +
|
|
|
|
|
// TODO(sorvell): move to compile-time conditional when supported
|
|
|
|
|
'Polymer.Element can create dom as children instead of in ' +
|
|
|
|
|
'ShadowDOM by setting `this.root = this;\` before \`ready\`.');
|
2016-08-11 18:07:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
|
|
|
|
* Provides a default implementation of the standard Custom Elements
|
|
|
|
|
* `attributeChangedCallback`.
|
|
|
|
|
*
|
|
|
|
|
* By default, attributes declared in `properties` metadata are
|
|
|
|
|
* deserialized using their `type` information to properties of the
|
|
|
|
|
* same name. "Dash-cased" attributes are deserialzed to "camelCase"
|
|
|
|
|
* properties.
|
|
|
|
|
*
|
|
|
|
|
* @override
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
attributeChangedCallback(name, old, value) {
|
|
|
|
|
if (old !== value) {
|
|
|
|
|
let property = caseMap.dashToCamelCase(name);
|
|
|
|
|
let type = propertiesForClass(this.constructor)[property].type;
|
|
|
|
|
if (!this._hasReadOnlyEffect(property)) {
|
|
|
|
|
this._attributeToProperty(name, value, type);
|
|
|
|
|
}
|
2016-08-26 10:29:44 -07:00
|
|
|
}
|
2016-08-11 18:07:41 -07:00
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
/**
|
2017-02-28 16:19:24 -08:00
|
|
|
* When using the ShadyCSS scoping and custom property shim, causes all
|
|
|
|
|
* shimmed styles in this element (and its subtree) to be updated
|
|
|
|
|
* based on current custom property values.
|
2017-02-27 16:06:41 -08:00
|
|
|
*
|
2017-02-28 16:19:24 -08:00
|
|
|
* The optional parameter overrides inline custom property styles with an
|
|
|
|
|
* object of properties where the keys are CSS properties, and the values
|
|
|
|
|
* are strings.
|
|
|
|
|
*
|
|
|
|
|
* Example: `this.updateStyles({'--color': 'blue'})`
|
|
|
|
|
*
|
|
|
|
|
* These properties are retained unless a value of `null` is set.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object=} properties Bag of custom property key/values to
|
|
|
|
|
* apply to this element.
|
2017-02-27 16:06:41 -08:00
|
|
|
*/
|
|
|
|
|
updateStyles(properties) {
|
|
|
|
|
if (window.ShadyCSS) {
|
|
|
|
|
window.ShadyCSS.styleSubtree(this, properties);
|
|
|
|
|
}
|
2017-02-16 12:24:03 -08:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
|
|
|
|
|
/**
|
2017-02-28 12:20:32 -08:00
|
|
|
* Rewrites a given URL relative to a base URL. The base URL defaults to
|
|
|
|
|
* the original location of the document containing the `dom-module` for
|
|
|
|
|
* this element. This method will return the same URL before and after
|
|
|
|
|
* bundling.
|
2017-02-27 16:06:41 -08:00
|
|
|
*
|
|
|
|
|
* @param {string} url URL to resolve.
|
2017-02-28 12:20:32 -08:00
|
|
|
* @param {string=} base Optional base URL to resolve against, defaults
|
2017-03-01 19:37:17 -08:00
|
|
|
* to the element's `importPath`
|
|
|
|
|
* @return {string} Rewritten URL relative to base
|
2017-02-27 16:06:41 -08:00
|
|
|
*/
|
2017-02-28 12:20:32 -08:00
|
|
|
resolveUrl(url, base) {
|
2017-03-02 17:38:43 -08:00
|
|
|
if (!base && this.importPath) {
|
|
|
|
|
base = Polymer.ResolveUrl.resolveUrl(this.importPath);
|
|
|
|
|
}
|
|
|
|
|
return Polymer.ResolveUrl.resolveUrl(url, base);
|
2017-02-27 16:06:41 -08:00
|
|
|
}
|
|
|
|
|
|
2016-08-11 18:07:41 -07:00
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
return PolymerElement;
|
|
|
|
|
});
|
|
|
|
|
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
|
|
|
|
* Provides basic tracking of element definitions (registrations) and
|
|
|
|
|
* instance counts.
|
|
|
|
|
*
|
|
|
|
|
* @namespace
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
Polymer.telemetry = {
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
|
|
|
|
* Total number of Polymer element instances created.
|
|
|
|
|
* @type {number}
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
instanceCount: 0,
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
|
|
|
|
* Array of Polymer element classes that have been finalized.
|
|
|
|
|
* @type {Array<Polymer.Element>}
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
registrations: [],
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
_regLog: function(prototype) {
|
|
|
|
|
console.log('[' + prototype.is + ']: registered')
|
|
|
|
|
},
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
|
|
|
|
* Registers a class prototype for telemetry purposes.
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
register: function(prototype) {
|
|
|
|
|
this.registrations.push(prototype);
|
|
|
|
|
Polymer.log && this._regLog(prototype);
|
|
|
|
|
},
|
2017-02-28 17:07:32 -08:00
|
|
|
/**
|
|
|
|
|
* Logs all elements registered with an `is` to the console.
|
|
|
|
|
* @public
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
dumpRegistrations: function() {
|
|
|
|
|
this.registrations.forEach(this._regLog);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-02-28 16:19:24 -08:00
|
|
|
/**
|
|
|
|
|
* When using the ShadyCSS scoping and custom property shim, causes all
|
|
|
|
|
* shimmed `styles` (via `custom-style`) in the document (and its subtree)
|
|
|
|
|
* to be updated based on current custom property values.
|
|
|
|
|
*
|
|
|
|
|
* The optional parameter overrides inline custom property styles with an
|
|
|
|
|
* object of properties where the keys are CSS properties, and the values
|
|
|
|
|
* are strings.
|
|
|
|
|
*
|
|
|
|
|
* Example: `Polymer.updateStyles({'--color': 'blue'})`
|
|
|
|
|
*
|
|
|
|
|
* These properties are retained unless a value of `null` is set.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object=} properties Bag of custom property key/values to
|
|
|
|
|
* apply to the document.
|
|
|
|
|
*/
|
2017-02-27 16:06:41 -08:00
|
|
|
Polymer.updateStyles = function(props) {
|
|
|
|
|
if (window.ShadyCSS) {
|
|
|
|
|
window.ShadyCSS.styleDocument(props);
|
2017-02-15 20:16:03 -08:00
|
|
|
}
|
2017-02-27 16:06:41 -08:00
|
|
|
};
|
2016-08-11 18:07:41 -07:00
|
|
|
|
2017-03-03 11:34:46 -08:00
|
|
|
/**
|
|
|
|
|
* Globally settable property that is automatically assigned to
|
|
|
|
|
* `Polymer.ElementMixin` instances, useful for binding in templates to
|
|
|
|
|
* make URL's relative to an application's root. Defaults to the main
|
|
|
|
|
* document URL, but can be overridden by users. It may be useful to set
|
|
|
|
|
* `Polymer.rootPath` to provide a stable application mount path when
|
|
|
|
|
* using client side routing.
|
|
|
|
|
*
|
|
|
|
|
* @memberof Polymer
|
|
|
|
|
*/
|
|
|
|
|
Polymer.rootPath = Polymer.rootPath ||
|
|
|
|
|
Polymer.ResolveUrl.pathFromUrl(document.baseURI || window.location.href);
|
|
|
|
|
|
2017-02-27 16:06:41 -08:00
|
|
|
})();
|
2016-08-11 18:07:41 -07:00
|
|
|
</script>
|