mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'master' into micro-perf
This commit is contained in:
commit
061e1b39e9
@ -2,9 +2,9 @@
|
||||
|
||||
There are many ways to contribute to the Polymer project! We welcome and truly appreciate contribution in all forms - issues and pull requests to the [main library](https://github.com/polymer/polymer), issues and pull requests to the [elements the Polymer team maintains](https://github.com/polymerelements), issues and pull requests to one of our many [Polymer-related tools](https://github.com/polymer), and of course we love to hear about any Polymer elements that you build to share with the community!
|
||||
|
||||
# Logistics
|
||||
## Logistics
|
||||
|
||||
## Communicating with the Polymer team
|
||||
### Communicating with the Polymer team
|
||||
|
||||
Beyond Github, we try to have a variety of different lines of communication open:
|
||||
|
||||
@ -14,7 +14,7 @@ Beyond Github, we try to have a variety of different lines of communication open
|
||||
* [Mailing list](https://groups.google.com/forum/#!forum/polymer-dev)
|
||||
* [Slack channel](https://bit.ly/polymerslack)
|
||||
|
||||
## The Polymer Repositories
|
||||
### The Polymer Repositories
|
||||
|
||||
Because of the component-based nature of the Polymer project, we tend to have lots of different repositories. Our main repository for the Polymer library itself is at [github.com/Polymer/polymer](https://github.com/polymer/polymer). File any issues or pull requests that have to do with the core library on that repository, and we'll take a look ASAP.
|
||||
|
||||
@ -24,7 +24,7 @@ The GoogleWebComponents element product line is maintained by teams all across G
|
||||
|
||||
We also track each element product line overall in "meta-repos", named as `$PRODUCTLINE-elements`. These include [paper-elements](https://github.com/polymerelements/paper-elements), [iron-elements](https://github.com/polymerelements/iron-elements), [gold-elements](https://github.com/polymerelements/gold-elements), and more. Feel free to file issues for element requests on those meta-repos, and the README in each repo tracks a roadmap for the product line.
|
||||
|
||||
## Contributor License Agreement
|
||||
### Contributor License Agreement
|
||||
|
||||
You might notice our friendly CLA-bot commenting on a pull request you open if you haven't yet signed our CLA. We use the same CLA for all open-source Google projects, so you only have to sign it once. Once you complete the CLA, all your pull-requests will automatically get the `cla: yes` tag.
|
||||
|
||||
@ -32,9 +32,9 @@ If you've already signed a CLA but are still getting bothered by the awfully ins
|
||||
|
||||
[Complete the CLA](https://cla.developers.google.com/clas)
|
||||
|
||||
# Contributing
|
||||
## Contributing
|
||||
|
||||
## Filing bugs
|
||||
### Filing bugs
|
||||
|
||||
The Polymer team heavily uses (and loves!) Github for all of our software management. We use Github issues to track all bugs and features.
|
||||
|
||||
@ -46,7 +46,7 @@ We love examples for addressing issues - issues with a Plunkr, jsFiddle, or jsBi
|
||||
|
||||
Occasionally we'll close issues if they appear stale or are too vague - please don't take this personally! Please feel free to re-open issues we've closed if there's something we've missed and they still need to be addressed.
|
||||
|
||||
## Contributing Pull Requests
|
||||
### Contributing Pull Requests
|
||||
|
||||
PR's are even better than issues. We gladly accept community pull requests. In general across the core library and all of the elements, there are a few necessary steps before we can accept a pull request:
|
||||
|
||||
@ -55,20 +55,98 @@ PR's are even better than issues. We gladly accept community pull requests. In g
|
||||
- Fork the repo you're making the fix on to your own Github account.
|
||||
- Code!
|
||||
- Ideally, squash your commits into a single commit with a clear message of what the PR does. If it absolutely makes sense to keep multiple commits, that's OK - or perhaps consider making two separate PR's.
|
||||
- **Include tests that test the range of behavior that changes with your PR.** If you PR fixes a bug, make sure your tests capture that bug. If your PR adds new behavior, make sure that behavior is fully tested. Every PR *must* include associated tests.
|
||||
- **Include tests that test the range of behavior that changes with your PR.** If you PR fixes a bug, make sure your tests capture that bug. If your PR adds new behavior, make sure that behavior is fully tested. Every PR *must* include associated tests. (See [Unit tests](#unit-tests) for more.)
|
||||
- Submit your PR, making sure it references the issue you created.
|
||||
- If your PR fixes a bug, make sure the issue includes clear steps to reproduce the bug so we can test your fix.
|
||||
|
||||
If you've completed all of these steps the core team will do its best to respond to the PR as soon as possible.
|
||||
|
||||
### Contributing Code to Elements
|
||||
#### Contributing Code to Elements
|
||||
|
||||
Though the aim of the Polymer library is to allow lots of flexibility and not get in your way, we work to standardize our elements to make them as toolable and easy to maintain as possible.
|
||||
|
||||
All elements should follow the [Polymer element style guide](http://polymerelements.github.io/style-guide/), which defines how to specify properties, documentation, and more. It's a great guide to follow when building your own elements as well, for maximum standardization and toolability. For instance, structuring elements following the style guide will ensure that they work with the [`iron-component-page`](https://github.com/polymerelements/iron-component-page) element, an incredibly easy way to turn any raw element directly into a documentation page.
|
||||
|
||||
### Contributing Code to the Polymer library
|
||||
#### Contributing Code to the Polymer library
|
||||
|
||||
We follow the most common javascript and HTML style guidelines for how we structure our code - in general, look at the code and you'll know how to contribute! If you'd like a bit more structure, the [Google Javascript Styleguide](https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml) is a good place to start.
|
||||
|
||||
Polymer also participates in Google's [Patch Rewards Program](http://www.google.com/about/appsecurity/patch-rewards/), where you can earn cold, hard cash for qualifying security patches to the Polymer library. Visit the [patch rewards page](http://www.google.com/about/appsecurity/patch-rewards/) to find out more.
|
||||
|
||||
## Unit tests
|
||||
|
||||
All Polymer projects use [`web-component-tester`](https://github.com/Polymer/web-component-tester) for unit tests.
|
||||
The [`polyserve`](https://github.com/PolymerLabs/polyserve) utility is helpful for running tests in the browser.
|
||||
|
||||
For maximum flexibility, install `web-component-tester` and `polyserve` locally:
|
||||
|
||||
npm install -g polyserve web-component-tester
|
||||
|
||||
### Running the Polymer library unit tests
|
||||
|
||||
To run the Polymer library unit tests:
|
||||
|
||||
1. Clone the [Polymer repo](https://github.com/polymer/polymer).
|
||||
|
||||
2. Install the dependencies:
|
||||
|
||||
npm install && bower install
|
||||
|
||||
3. Run the tests:
|
||||
|
||||
npm test
|
||||
|
||||
Or if you have `web-component-tester` installed locally:
|
||||
|
||||
wct
|
||||
|
||||
To run individual test suites:
|
||||
|
||||
<code>npm test <var>path/to/suite</var></code>
|
||||
|
||||
Or:
|
||||
|
||||
<code>wct <var>path/to/suite</var></code>
|
||||
|
||||
For example:
|
||||
|
||||
npm test test/unit/template.html
|
||||
|
||||
You can also run tests in the browser:
|
||||
|
||||
polyserve
|
||||
|
||||
Navigate to [`http://localhost:8080/components/polymer/test/runner.html`](http://localhost:8080/components/polymer/test/runner.html).
|
||||
|
||||
### Running Polymer element unit tests
|
||||
|
||||
To run the element unit tests, you need a global
|
||||
install of `web-component-tester` or `polyserve` (or both).
|
||||
|
||||
1. Clone the element repo.
|
||||
|
||||
2. Install the dependencies.
|
||||
|
||||
bower install
|
||||
|
||||
3. Run the tests:
|
||||
|
||||
wct
|
||||
|
||||
Or run the tests in a browser:
|
||||
|
||||
polyserve
|
||||
|
||||
Navigate to:
|
||||
|
||||
<code>http://localhost:8080/components/<var>element-name</var>/test/runner.html</code>
|
||||
|
||||
### Configuring `web-component-tester`
|
||||
|
||||
By default, `web-component-tester` runs tests on all installed browsers. You can configure it
|
||||
to run tests on a subset of available browsers, or to run tests remotely using Sauce Labs.
|
||||
|
||||
See the [`web-component-tester` README](https://github.com/Polymer/web-component-tester) for
|
||||
information on configuring the tool.
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ See [the full Polymer.Base API documentation](http://polymer.github.io/polymer/)
|
||||
| Feature | Usage
|
||||
|---------|-------
|
||||
| [Local node marshaling](#node-marshaling) | this.$.\<id>
|
||||
| [Event listener setup](#event-listeners)| listeners: { ‘\<node>.\<event>’: ‘function’, ... }
|
||||
| [Host event listener setup](#event-listeners)| listeners: { ‘\<event>’: ‘function’, ... }
|
||||
| [Annotated event listener setup](#annotated-listeners) | \<element on-[event]=”function”>
|
||||
| [Gesture event support](#gesture-events) | \<element on-[gesture-event]=”function”>
|
||||
|
||||
|
@ -89,7 +89,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
this._parseElementAnnotations(node, list, stripWhiteSpace);
|
||||
},
|
||||
|
||||
_bindingRegex: /([^{[]*)({{|\[\[)([^}\]]*)(?:]]|}})/g,
|
||||
_bindingRegex: /([^{[]*)(\{\{|\[\[)(?!\}\}|\]\])(.+?)(?:\]\]|\}\})/g,
|
||||
|
||||
// TODO(kschaaf): We could modify this to allow an escape mechanism by
|
||||
// looking for the escape sequence in each of the matches and converting
|
||||
|
@ -12,8 +12,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<script>
|
||||
|
||||
/**
|
||||
* DomApi is a dom manipulation library which is compatible with both
|
||||
* Shady DOM and Shadow DOM. The general usage is
|
||||
* DomApi is a dom manipulation library which is compatible with both
|
||||
* Shady DOM and Shadow DOM. The general usage is
|
||||
* `Polymer.dom(node).method(arguments)` where methods and arguments
|
||||
* match native DOM where possible.
|
||||
*/
|
||||
@ -29,23 +29,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
var nativeCloneNode = Element.prototype.cloneNode;
|
||||
var nativeImportNode = Document.prototype.importNode;
|
||||
|
||||
// ensure nodes are wrapped if SD polyfill is present
|
||||
var needsToWrap = Settings.hasShadow && !Settings.nativeShadow;
|
||||
var wrap = window.wrap ? window.wrap : function(node) { return node; };
|
||||
|
||||
var DomApi = function(node) {
|
||||
this.node = node;
|
||||
this.node = needsToWrap ? wrap(node) : node;
|
||||
if (this.patch) {
|
||||
this.patch();
|
||||
}
|
||||
};
|
||||
|
||||
// ensure nodes are wrapped if SD polyfill is present
|
||||
if (window.wrap && Settings.useShadow && !Settings.useNativeShadow) {
|
||||
DomApi = function(node) {
|
||||
this.node = wrap(node);
|
||||
if (this.patch) {
|
||||
this.patch();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
DomApi.prototype = {
|
||||
|
||||
flush: function() {
|
||||
@ -79,7 +73,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// we don't distribute before initial distribution
|
||||
if (host.shadyRoot && host.shadyRoot._distributionClean) {
|
||||
host.shadyRoot._distributionClean = false;
|
||||
Polymer.dom.addDebouncer(host.debounce('_distribute',
|
||||
Polymer.dom.addDebouncer(host.debounce('_distribute',
|
||||
host._distributeContent));
|
||||
}
|
||||
},
|
||||
@ -119,7 +113,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
this._addNodeToHost(node);
|
||||
// if not distributing and not adding to host, do a fast path addition
|
||||
if (!this._maybeDistribute(node, this.node) &&
|
||||
if (!this._maybeDistribute(node, this.node) &&
|
||||
!this._tryRemoveUndistributedNode(node)) {
|
||||
if (ref_node) {
|
||||
// if ref_node is <content> replace with first distributed node
|
||||
@ -224,7 +218,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
var root = this._ownerShadyRootForNode(parent);
|
||||
if (root) {
|
||||
var host = root.host;
|
||||
// note, insertion point list update is handled after node
|
||||
// note, insertion point list update is handled after node
|
||||
// mutations are complete
|
||||
this._lazyDistribute(host);
|
||||
}
|
||||
@ -245,7 +239,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
of date parent at this point; returns true if a <content> is being added */
|
||||
_maybeAddInsertionPoint: function(node, parent) {
|
||||
var added;
|
||||
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&
|
||||
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&
|
||||
!node.__noContent) {
|
||||
var c$ = factory(node).querySelectorAll(CONTENT);
|
||||
for (var i=0, n, np, na; (i<c$.length) && (n=c$[i]); i++) {
|
||||
@ -308,7 +302,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// NOTE: if `ensureComposedRemoval` is true then the node should be
|
||||
// removed from its composed parent.
|
||||
_removeNodeFromHost: function(node, ensureComposedRemoval) {
|
||||
// note that it's possible for both the node's host and its parent
|
||||
// note that it's possible for both the node's host and its parent
|
||||
// to require distribution... both cases are handled here.
|
||||
var hostNeedsDist;
|
||||
var root;
|
||||
@ -477,7 +471,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
var c$ = this.getEffectiveChildNodes();
|
||||
var list = [];
|
||||
for (var i=0, l=c$.length, c; (i<l) && (c=c$[i]); i++) {
|
||||
if ((c.nodeType === Node.ELEMENT_NODE) &&
|
||||
if ((c.nodeType === Node.ELEMENT_NODE) &&
|
||||
matchesSelector.call(c, selector)) {
|
||||
list.push(c);
|
||||
}
|
||||
@ -558,14 +552,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
},
|
||||
|
||||
/**
|
||||
* Notifies callers about changes to the element's effective child nodes,
|
||||
* the same list as returned by `getEffectiveChildNodes`.
|
||||
* @param {function} callback The supplied callback is called with an
|
||||
* `info` argument which is an object that provides
|
||||
* the `target` on which the changes occurred, a list of any nodes
|
||||
* added in the `addedNodes` array, and nodes removed in the
|
||||
* Notifies callers about changes to the element's effective child nodes,
|
||||
* the same list as returned by `getEffectiveChildNodes`.
|
||||
* @param {function} callback The supplied callback is called with an
|
||||
* `info` argument which is an object that provides
|
||||
* the `target` on which the changes occurred, a list of any nodes
|
||||
* added in the `addedNodes` array, and nodes removed in the
|
||||
* `removedNodes` array.
|
||||
* @return {object} Returns a handle which is the argument to
|
||||
* @return {object} Returns a handle which is the argument to
|
||||
* `unobserveNodes`.
|
||||
*/
|
||||
observeNodes: function(callback) {
|
||||
@ -582,7 +576,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
/**
|
||||
* Stops observing changes to the element's effective child nodes.
|
||||
* @param {object} handle The handle for the callback that should
|
||||
* no longer receive notifications. This handle is returned from
|
||||
* no longer receive notifications. This handle is returned from
|
||||
* `observeNodes`.
|
||||
*/
|
||||
unobserveNodes: function(handle) {
|
||||
@ -744,7 +738,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
this._clear();
|
||||
var d = document.createElement('div');
|
||||
d.innerHTML = text;
|
||||
// here, appendChild may move nodes async so we cannot rely
|
||||
// here, appendChild may move nodes async so we cannot rely
|
||||
// on node position when copying
|
||||
var c$ = arrayCopyChildNodes(d);
|
||||
for (var i=0; i < c$.length; i++) {
|
||||
@ -776,7 +770,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
};
|
||||
|
||||
forwardMethods(['cloneNode', 'appendChild', 'insertBefore',
|
||||
forwardMethods(['cloneNode', 'appendChild', 'insertBefore',
|
||||
'removeChild', 'replaceChild']);
|
||||
|
||||
DomApi.prototype.querySelectorAll = function(selector) {
|
||||
@ -800,13 +794,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
|
||||
DomApi.prototype.getDestinationInsertionPoints = function() {
|
||||
var n$ = this.node.getDestinationInsertionPoints &&
|
||||
var n$ = this.node.getDestinationInsertionPoints &&
|
||||
this.node.getDestinationInsertionPoints();
|
||||
return n$ ? arrayCopy(n$) : [];
|
||||
};
|
||||
|
||||
DomApi.prototype.getDistributedNodes = function() {
|
||||
var n$ = this.node.getDistributedNodes &&
|
||||
var n$ = this.node.getDistributedNodes &&
|
||||
this.node.getDistributedNodes();
|
||||
return n$ ? arrayCopy(n$) : [];
|
||||
};
|
||||
@ -857,7 +851,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
forwardProperty(f$[i]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var forwardProperty = function(name) {
|
||||
Object.defineProperty(DomApi.prototype, name, {
|
||||
get: function() {
|
||||
@ -867,8 +861,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
});
|
||||
};
|
||||
|
||||
forwardProperties(['parentNode', 'firstChild', 'lastChild',
|
||||
'nextSibling', 'previousSibling', 'firstElementChild',
|
||||
forwardProperties(['parentNode', 'firstChild', 'lastChild',
|
||||
'nextSibling', 'previousSibling', 'firstElementChild',
|
||||
'lastElementChild', 'nextElementSibling', 'previousElementSibling']);
|
||||
|
||||
}
|
||||
@ -1009,7 +1003,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
hasDomApi: hasDomApi,
|
||||
arrayCopy: arrayCopy,
|
||||
arrayCopyChildNodes: arrayCopyChildNodes,
|
||||
arrayCopyChildren: arrayCopyChildren
|
||||
arrayCopyChildren: arrayCopyChildren,
|
||||
wrap: wrap
|
||||
};
|
||||
|
||||
})();
|
||||
|
@ -67,7 +67,7 @@ Polymer.StyleExtends = (function() {
|
||||
if (target.parent !== source.parent) {
|
||||
this._cloneAndAddRuleToParent(source, target.parent);
|
||||
}
|
||||
target.extends = target.extends || (target.extends = []);
|
||||
target.extends = target.extends || [];
|
||||
target.extends.push(source);
|
||||
// TODO: this misses `%foo, .bar` as an unetended selector but
|
||||
// this seems rare and could possibly be unsupported.
|
||||
|
@ -117,12 +117,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
_ensureInstance: function() {
|
||||
if (!this._instance) {
|
||||
// TODO(sorvell): pickup stamping logic from x-repeat
|
||||
this._instance = this.stamp();
|
||||
var root = this._instance.root;
|
||||
// TODO(sorvell): this incantation needs to be simpler.
|
||||
var parent = Polymer.dom(Polymer.dom(this).parentNode);
|
||||
parent.insertBefore(root, this);
|
||||
var parentNode = Polymer.dom(this).parentNode;
|
||||
// Guard against element being detached while render was queued
|
||||
if (parentNode) {
|
||||
var parent = Polymer.dom(parentNode);
|
||||
// TODO(sorvell): pickup stamping logic from x-repeat
|
||||
this._instance = this.stamp();
|
||||
var root = this._instance.root;
|
||||
// TODO(sorvell): this incantation needs to be simpler.
|
||||
parent.insertBefore(root, this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -12,6 +12,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
'use strict';
|
||||
|
||||
var wrap = Polymer.DomApi.wrap;
|
||||
|
||||
// detect native touch action support
|
||||
var HAS_NATIVE_TA = typeof document.head.style.touchAction === 'string';
|
||||
var GESTURE_KEY = '__polymerGestures';
|
||||
@ -199,8 +201,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
handleNative: function(ev) {
|
||||
var handled;
|
||||
var type = ev.type;
|
||||
var node = ev.currentTarget;
|
||||
var node = wrap(ev.currentTarget);
|
||||
var gobj = node[GESTURE_KEY];
|
||||
if (!gobj) {
|
||||
return;
|
||||
}
|
||||
var gs = gobj[type];
|
||||
if (!gs) {
|
||||
return;
|
||||
@ -292,6 +297,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
// automate the event listeners for the native events
|
||||
add: function(node, evType, handler) {
|
||||
// SD polyfill: handle case where `node` is unwrapped, like `document`
|
||||
node = wrap(node);
|
||||
var recognizer = this.gestures[evType];
|
||||
var deps = recognizer.deps;
|
||||
var name = recognizer.name;
|
||||
@ -323,6 +330,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
// automate event listener removal for native events
|
||||
remove: function(node, evType, handler) {
|
||||
// SD polyfill: handle case where `node` is unwrapped, like `document`
|
||||
node = wrap(node);
|
||||
var recognizer = this.gestures[evType];
|
||||
var deps = recognizer.deps;
|
||||
var name = recognizer.name;
|
||||
|
@ -158,7 +158,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
},
|
||||
|
||||
queryAllEffectiveChildren: function(slctr) {
|
||||
return Polymer.dom(this).queryAllDistributedElements(slctr);
|
||||
return Polymer.dom(this).queryDistributedElements(slctr);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -43,6 +43,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
'unit/array-selector.html',
|
||||
'unit/events.html',
|
||||
'unit/gestures.html',
|
||||
'unit/gestures.html?dom=shadow',
|
||||
'unit/utils.html',
|
||||
'unit/utils-content.html',
|
||||
'unit/utils.html?dom=shadow',
|
||||
|
@ -26,6 +26,7 @@
|
||||
no-computed="{{foobared(noInlineComputed)}}"
|
||||
compoundAttr1$="{{cpnd1}}{{ cpnd2 }}{{cpnd3.prop}}{{ computeCompound(cpnd4, cpnd5, 'literal')}}"
|
||||
compoundAttr2$="literal1 {{cpnd1}} literal2 {{cpnd2}}{{cpnd3.prop}} literal3 {{computeCompound(cpnd4, cpnd5, 'literal')}} literal4"
|
||||
compoundAttr3$="{{computeCompound('world', 'username ', 'Hello {0} ')}}"
|
||||
>
|
||||
Test
|
||||
</div>
|
||||
|
@ -767,6 +767,12 @@ suite('compound binding / string interpolation', function() {
|
||||
assert.equal(el.$.boundChild.getAttribute('compoundAttr2'), 'literal1 literal2 literal3 literal literal4');
|
||||
});
|
||||
|
||||
test('compound property attribute with {} in text', function() {
|
||||
var el = document.createElement('x-basic');
|
||||
|
||||
assert.equal(el.$.boundChild.getAttribute('compoundAttr3'), 'Hello {0} username world')
|
||||
})
|
||||
|
||||
test('compound adjacent textNode bindings', function() {
|
||||
var el = document.createElement('x-basic');
|
||||
// The single space is due to the gambit to prevent empty text nodes
|
||||
|
@ -56,6 +56,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<template is="dom-if" id="simple">
|
||||
<div></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
suite('nested pre-configured dom-if', function() {
|
||||
@ -493,6 +497,22 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
});
|
||||
|
||||
suite('queueing race conditions', function() {
|
||||
|
||||
test('domif=true, attach, detach', function(done) {
|
||||
var domif = document.querySelector('#simple');
|
||||
domif.if = true;
|
||||
document.body.appendChild(domif);
|
||||
document.body.removeChild(domif);
|
||||
setTimeout(function() {
|
||||
document.body.appendChild(domif);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
@ -139,3 +139,28 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
|
||||
<dom-module id="x-document-listener">
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'x-document-listener',
|
||||
properties: {
|
||||
stream: {
|
||||
type: Array,
|
||||
value: function() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function() {
|
||||
this.listen(document, 'down', 'handler');
|
||||
},
|
||||
teardown: function() {
|
||||
this.unlisten(document, 'down', 'handler');
|
||||
},
|
||||
handler: function(e) {
|
||||
this.stream.push(e);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
|
@ -12,7 +12,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../../webcomponentsjs/webcomponents.js"></script>
|
||||
<script src="../../../web-component-tester/browser.js"></script>
|
||||
|
||||
<link rel="import" href="../../polymer.html">
|
||||
@ -386,6 +386,26 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('SD Polyfill', function() {
|
||||
var el;
|
||||
setup(function() {
|
||||
el = document.createElement('x-document-listener');
|
||||
document.body.appendChild(el);
|
||||
el.setup();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
el.teardown();
|
||||
document.body.removeChild(el);
|
||||
});
|
||||
|
||||
test('document listener works in SD polyfill', function() {
|
||||
var ev = new CustomEvent('mousedown', {bubbles: true});
|
||||
el.dispatchEvent(ev);
|
||||
assert.equal(el.stream.length, 1);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
@ -349,3 +349,11 @@
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
|
||||
<dom-module id="x-wrapped">
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'x-wrapped'
|
||||
});
|
||||
</script>
|
||||
</dom-module>
|
||||
|
@ -55,6 +55,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
<x-deep-contains></x-deep-contains>
|
||||
|
||||
<x-wrapped></x-wrapped>
|
||||
|
||||
<script src="polymer-dom.js"></script>
|
||||
|
||||
</body>
|
||||
|
@ -55,6 +55,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
<x-deep-contains></x-deep-contains>
|
||||
|
||||
<x-wrapped></x-wrapped>
|
||||
|
||||
<script src="polymer-dom.js"></script>
|
||||
|
||||
</body>
|
||||
|
@ -936,4 +936,13 @@ suite('Polymer.dom non-distributed elements', function() {
|
||||
|
||||
document.body.removeChild(separate);
|
||||
});
|
||||
|
||||
test('Polymer.DomApi.wrap', function() {
|
||||
var wrap = window.wrap || function(node) { return node; };
|
||||
|
||||
var node = document.querySelector('x-wrapped');
|
||||
assert.equal(wrap(document), Polymer.DomApi.wrap(document), 'document should be wrapped');
|
||||
assert.equal(wrap(node), Polymer.DomApi.wrap(node), 'node should be wrapped');
|
||||
assert.equal(wrap(node), Polymer.dom(node).node, 'Polymer.dom should always wrap the input node');
|
||||
});
|
||||
});
|
||||
|
@ -124,6 +124,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
assert.equal(text.replace(/\s/g, ''), 'abcde');
|
||||
});
|
||||
|
||||
test('queryAllEffectiveChildren', function() {
|
||||
var nodes = elt7.$.content.queryAllEffectiveChildren('div:not(.a)');
|
||||
var aNode = elt7.$.content.queryAllEffectiveChildren('.a');
|
||||
assert.equal(nodes.length, 4);
|
||||
assert.equal(aNode.length, 1);
|
||||
assert.ok(nodes[0].classList.contains('b'));
|
||||
assert.ok(nodes[1].classList.contains('c'));
|
||||
assert.ok(nodes[2].classList.contains('d'));
|
||||
assert.ok(nodes[3].classList.contains('e'));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
suite('isLight/Local descendant utils', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user