Skip to content

Commit

Permalink
polymer: add missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo committed Mar 11, 2017
1 parent 3e29b53 commit 77eb824
Show file tree
Hide file tree
Showing 39 changed files with 11,151 additions and 0 deletions.
404 changes: 404 additions & 0 deletions lib/polymer2/bower_components/polymer/lib/elements/array-selector.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!--
@license
Copyright (c) 2017 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
-->
<link rel="import" href="../../../shadycss/custom-style-interface.html">
<link rel="import" href="../utils/style-gather.html">
<script>
(function() {
'use strict';

const attr = 'include';

const CustomStyleInterface = window.ShadyCSS.CustomStyleInterface;

/**
* Custom element for defining styles in the main document that can take
* advantage of several special features of Polymer's styling system:
*
* - Document styles defined in a custom-style are shimmed to ensure they
* do not leak into local DOM when running on browsers without native
* Shadow DOM.
* - Custom properties used by Polymer's shim for cross-scope styling may
* be defined in an custom-style. Use the :root selector to define custom
* properties that apply to all custom elements.
*
* To use, simply wrap an inline `<style>` tag in the main document whose
* CSS uses these features with a `<custom-style>` element.
*
* @extends HTMLElement
* @memberof Polymer
* @summary Custom element for defining styles in the main document that can
* take advantage of Polymer's style scoping and custom properties shims.
*/
class CustomStyle extends HTMLElement {
constructor() {
super();
this._style = null;
CustomStyleInterface.addCustomStyle(this);
}
/**
* Returns the light-DOM `<style>` child this element wraps. Upon first
* call any style modules referenced via the `include` attribute will be
* concatenated to this element's `<style>`.
*
* @return {HTMLStyleElement} This element's light-DOM `<style>`
*/
getStyle() {
if (this._style) {
return this._style;
}
const style = this.querySelector('style');
if (!style) {
return;
}
this._style = style;
const include = style.getAttribute(attr);
if (include) {
style.removeAttribute(attr);
style.textContent = Polymer.StyleGather.cssFromModules(include) + style.textContent;
}
return this._style;
}
}

window.customElements.define('custom-style', CustomStyle);
Polymer.CustomStyle = CustomStyle;
})();
</script>
109 changes: 109 additions & 0 deletions lib/polymer2/bower_components/polymer/lib/elements/dom-bind.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<!--
@license
Copyright (c) 2017 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
-->

<link rel="import" href="../utils/boot.html">
<link rel="import" href="../mixins/property-effects.html">

<script>

(function() {
'use strict';

const domBindBase = Polymer.OptionalMutableData(Polymer.PropertyEffects(HTMLElement));

/**
* Custom element to allow using Polymer's template features (data binding,
* declarative event listeners, etc.) in the main document without defining
* a new custom element.
*
* `<template>` tags utilizing bindings may be wrapped with the `<dom-bind>`
* element, which will immediately stamp the wrapped template into the main
* document and bind elements to the `dom-bind` element itself as the
* binding scope.
*
* @extends HTMLElement
* @mixes Polymer.PropertyEffects
* @memberof Polymer
* @summary Custom element to allow using Polymer's template features (data
* binding, declarative event listeners, etc.) in the main document.
*/
class DomBind extends domBindBase {

static get observedAttributes() { return ['mutable-data'] }

// assumes only one observed attribute
attributeChangedCallback() {
this.mutableData = true;
}

connectedCallback() {
this.render();
}

disconnectedCallback() {
this.__removeChildren();
}

__insertChildren() {
this.parentNode.insertBefore(this.root, this);
}

__removeChildren() {
if (this.__children) {
for (let i=0; i<this.__children.length; i++) {
this.root.appendChild(this.__children[i]);
}
}
}

/**
* Forces the element to render its content. This is typically only
* necessary to call if HTMLImports with the async attribute are used.
*/
render() {
let template;
if (!this.__children) {
template = template || this.querySelector('template');
if (!template) {
// Wait until childList changes and template should be there by then
let observer = new MutationObserver(() => {
template = this.querySelector('template');
if (template) {
observer.disconnect();
this.render(template);
} else {
throw new Error('dom-bind requires a <template> child');
}
})
observer.observe(this, {childList: true});
return;
}
this._bindTemplate(template);
this.root = this._stampTemplate(template);
this.__children = [];
for (let n=this.root.firstChild; n; n=n.nextSibling) {
this.__children[this.__children.length] = n;
}
this._flushProperties();
}
this.__insertChildren();
this.dispatchEvent(new CustomEvent('dom-change', {
bubbles: true,
composed: true
}));
}

}

customElements.define('dom-bind', DomBind);

})();

</script>
Loading

0 comments on commit 77eb824

Please sign in to comment.