switch polymer to bower
This commit is contained in:
parent
b9598ffaa1
commit
8f6cbe8de2
348 changed files with 40895 additions and 310 deletions
38
dashboard-ui/bower_components/iron-meta/.bower.json
vendored
Normal file
38
dashboard-ui/bower_components/iron-meta/.bower.json
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "iron-meta",
|
||||
"version": "1.0.2",
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer"
|
||||
],
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"description": "Useful for sharing information across a DOM tree",
|
||||
"private": true,
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-meta.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"paper-styles": "polymerelements/paper-styles#^1.0.4",
|
||||
"iron-component-page": "polymerelements/iron-component-page#^1.0.0",
|
||||
"test-fixture": "polymerelements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "*",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"homepage": "https://github.com/polymerelements/iron-meta",
|
||||
"_release": "1.0.2",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.2",
|
||||
"commit": "85d0258556a25a34dbe98657ce9f40d878d4c5bf"
|
||||
},
|
||||
"_source": "git://github.com/polymerelements/iron-meta.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "polymerelements/iron-meta"
|
||||
}
|
1
dashboard-ui/bower_components/iron-meta/.gitignore
vendored
Normal file
1
dashboard-ui/bower_components/iron-meta/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
bower_components
|
28
dashboard-ui/bower_components/iron-meta/bower.json
vendored
Normal file
28
dashboard-ui/bower_components/iron-meta/bower.json
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "iron-meta",
|
||||
"version": "1.0.2",
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer"
|
||||
],
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"description": "Useful for sharing information across a DOM tree",
|
||||
"private": true,
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-meta.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"paper-styles": "polymerelements/paper-styles#^1.0.4",
|
||||
"iron-component-page": "polymerelements/iron-component-page#^1.0.0",
|
||||
"test-fixture": "polymerelements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "*",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
}
|
||||
}
|
46
dashboard-ui/bower_components/iron-meta/demo/index.html
vendored
Normal file
46
dashboard-ui/bower_components/iron-meta/demo/index.html
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 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
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>iron-meta</title>
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<link rel="import" href="../../paper-styles/demo-pages.html">
|
||||
<link rel="import" href="../iron-meta.html">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="vertical-section vertical-section-container centered">
|
||||
<h1><iron-meta></h1>
|
||||
<iron-meta key="info" value="foo/bar"></iron-meta>
|
||||
The <code>value</code> stored at <code>key="info"</code> is <code><meta-test></meta-test></code>.
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'meta-test',
|
||||
|
||||
ready: function() {
|
||||
this.textContent = new Polymer.IronMetaQuery({key: 'info'}).value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
33
dashboard-ui/bower_components/iron-meta/hero.svg
vendored
Normal file
33
dashboard-ui/bower_components/iron-meta/hero.svg
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
|
||||
<g id="background" display="none">
|
||||
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
|
||||
</g>
|
||||
<g id="label">
|
||||
</g>
|
||||
<g id="art">
|
||||
<circle cx="22" cy="85" r="4"/>
|
||||
<circle cx="88" cy="98" r="4"/>
|
||||
<path d="M87.5,100c-3.8-0.3-5.5-2.8-7-5c-1.4-2.1-2.7-3.9-5.5-4.2c-2.8-0.3-4.4,1.3-6.2,3.1c-1.9,1.9-4,4-7.8,3.7
|
||||
c-3.8-0.3-5.5-2.8-7-5c-1.4-2.1-2.7-3.9-5.5-4.2c-2.8-0.3-4.4,1.3-6.2,3.1c-1.9,1.9-4,4-7.8,3.7c-3.8-0.3-5.5-2.8-7-5
|
||||
c-1.4-2.1-2.7-3.9-5.5-4.2l0.2-2c3.8,0.3,5.5,2.8,7,5c1.4,2.1,2.7,3.9,5.5,4.2c2.8,0.3,4.4-1.3,6.2-3.1c1.9-1.9,4-4,7.8-3.7
|
||||
c3.8,0.3,5.5,2.8,7,5c1.4,2.1,2.7,3.9,5.5,4.2c2.8,0.3,4.4-1.3,6.2-3.1c1.9-1.9,4-4,7.8-3.7c3.8,0.3,5.5,2.8,7,5
|
||||
c1.4,2.1,2.7,3.9,5.5,4.2L87.5,100z"/>
|
||||
<circle cx="96" cy="86" r="4"/>
|
||||
<circle cx="162" cy="98" r="4"/>
|
||||
<rect x="95.5" y="91" transform="matrix(0.9839 0.1789 -0.1789 0.9839 18.5382 -21.5923)" width="67.1" height="2"/>
|
||||
<g>
|
||||
<path d="M27,41.5l4.5,13.4l4.9-13.4h5.4v32h-4.4V61l0.4-13.4l-5.4,14.5h-2L25.6,48L26,61v12.5h-4.4v-32H27z"/>
|
||||
<path d="M67.5,58.7H53.4V70h16.4v3.5H49v-32h20.6V45H53.4v10.2h14.2V58.7z"/>
|
||||
<path d="M98.5,45H88.3v28.5h-4.4V45H73.6v-3.5h24.9V45z"/>
|
||||
<path d="M116.2,65.3H105l-2.6,8.2h-4.5l10.9-32h3.8l10.6,32h-4.5L116.2,65.3z M106.2,61.6h8.9l-4.4-14.2L106.2,61.6z"/>
|
||||
</g>
|
||||
<g id="ic_x5F_add_x0D_">
|
||||
</g>
|
||||
</g>
|
||||
<g id="Guides">
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.7 KiB |
27
dashboard-ui/bower_components/iron-meta/index.html
vendored
Normal file
27
dashboard-ui/bower_components/iron-meta/index.html
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 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
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
||||
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
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>iron-meta</title>
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<link rel="import" href="../iron-component-page/iron-component-page.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<iron-component-page></iron-component-page>
|
||||
|
||||
</body>
|
||||
</html>
|
315
dashboard-ui/bower_components/iron-meta/iron-meta.html
vendored
Normal file
315
dashboard-ui/bower_components/iron-meta/iron-meta.html
vendored
Normal file
|
@ -0,0 +1,315 @@
|
|||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 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="../polymer/polymer.html">
|
||||
|
||||
<!--
|
||||
`iron-meta` is a generic element you can use for sharing information across the DOM tree.
|
||||
It uses [monostate pattern](http://c2.com/cgi/wiki?MonostatePattern) such that any
|
||||
instance of iron-meta has access to the shared
|
||||
information. You can use `iron-meta` to share whatever you want (or create an extension
|
||||
[like x-meta] for enhancements).
|
||||
|
||||
The `iron-meta` instances containing your actual data can be loaded in an import,
|
||||
or constructed in any way you see fit. The only requirement is that you create them
|
||||
before you try to access them.
|
||||
|
||||
Examples:
|
||||
|
||||
If I create an instance like this:
|
||||
|
||||
<iron-meta key="info" value="foo/bar"></iron-meta>
|
||||
|
||||
Note that value="foo/bar" is the metadata I've defined. I could define more
|
||||
attributes or use child nodes to define additional metadata.
|
||||
|
||||
Now I can access that element (and it's metadata) from any iron-meta instance
|
||||
via the byKey method, e.g.
|
||||
|
||||
meta.byKey('info').getAttribute('value').
|
||||
|
||||
Pure imperative form would be like:
|
||||
|
||||
document.createElement('iron-meta').byKey('info').getAttribute('value');
|
||||
|
||||
Or, in a Polymer element, you can include a meta in your template:
|
||||
|
||||
<iron-meta id="meta"></iron-meta>
|
||||
...
|
||||
this.$.meta.byKey('info').getAttribute('value');
|
||||
|
||||
@group Iron Elements
|
||||
@demo demo/index.html
|
||||
@hero hero.svg
|
||||
@element iron-meta
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
|
||||
// monostate data
|
||||
var metaDatas = {};
|
||||
var metaArrays = {};
|
||||
|
||||
Polymer.IronMeta = Polymer({
|
||||
|
||||
is: 'iron-meta',
|
||||
|
||||
properties: {
|
||||
|
||||
/**
|
||||
* The type of meta-data. All meta-data of the same type is stored
|
||||
* together.
|
||||
*/
|
||||
type: {
|
||||
type: String,
|
||||
value: 'default',
|
||||
observer: '_typeChanged'
|
||||
},
|
||||
|
||||
/**
|
||||
* The key used to store `value` under the `type` namespace.
|
||||
*/
|
||||
key: {
|
||||
type: String,
|
||||
observer: '_keyChanged'
|
||||
},
|
||||
|
||||
/**
|
||||
* The meta-data to store or retrieve.
|
||||
*/
|
||||
value: {
|
||||
type: Object,
|
||||
notify: true,
|
||||
observer: '_valueChanged'
|
||||
},
|
||||
|
||||
/**
|
||||
* If true, `value` is set to the iron-meta instance itself.
|
||||
*/
|
||||
self: {
|
||||
type: Boolean,
|
||||
observer: '_selfChanged'
|
||||
},
|
||||
|
||||
/**
|
||||
* Array of all meta-data values for the given type.
|
||||
*/
|
||||
list: {
|
||||
type: Array,
|
||||
notify: true
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Only runs if someone invokes the factory/constructor directly
|
||||
* e.g. `new Polymer.IronMeta()`
|
||||
*/
|
||||
factoryImpl: function(config) {
|
||||
if (config) {
|
||||
for (var n in config) {
|
||||
switch(n) {
|
||||
case 'type':
|
||||
case 'key':
|
||||
case 'value':
|
||||
this[n] = config[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
created: function() {
|
||||
// TODO(sjmiles): good for debugging?
|
||||
this._metaDatas = metaDatas;
|
||||
this._metaArrays = metaArrays;
|
||||
},
|
||||
|
||||
_keyChanged: function(key, old) {
|
||||
this._resetRegistration(old);
|
||||
},
|
||||
|
||||
_valueChanged: function(value) {
|
||||
this._resetRegistration(this.key);
|
||||
},
|
||||
|
||||
_selfChanged: function(self) {
|
||||
if (self) {
|
||||
this.value = this;
|
||||
}
|
||||
},
|
||||
|
||||
_typeChanged: function(type) {
|
||||
this._unregisterKey(this.key);
|
||||
if (!metaDatas[type]) {
|
||||
metaDatas[type] = {};
|
||||
}
|
||||
this._metaData = metaDatas[type];
|
||||
if (!metaArrays[type]) {
|
||||
metaArrays[type] = [];
|
||||
}
|
||||
this.list = metaArrays[type];
|
||||
this._registerKeyValue(this.key, this.value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves meta data value by key.
|
||||
*
|
||||
* @method byKey
|
||||
* @param {String} key The key of the meta-data to be returned.
|
||||
* @returns *
|
||||
*/
|
||||
byKey: function(key) {
|
||||
return this._metaData && this._metaData[key];
|
||||
},
|
||||
|
||||
_resetRegistration: function(oldKey) {
|
||||
this._unregisterKey(oldKey);
|
||||
this._registerKeyValue(this.key, this.value);
|
||||
},
|
||||
|
||||
_unregisterKey: function(key) {
|
||||
this._unregister(key, this._metaData, this.list);
|
||||
},
|
||||
|
||||
_registerKeyValue: function(key, value) {
|
||||
this._register(key, value, this._metaData, this.list);
|
||||
},
|
||||
|
||||
_register: function(key, value, data, list) {
|
||||
if (key && data && value !== undefined) {
|
||||
data[key] = value;
|
||||
list.push(value);
|
||||
}
|
||||
},
|
||||
|
||||
_unregister: function(key, data, list) {
|
||||
if (key && data) {
|
||||
if (key in data) {
|
||||
var value = data[key];
|
||||
delete data[key];
|
||||
this.arrayDelete(list, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
`iron-meta-query` can be used to access infomation stored in `iron-meta`.
|
||||
|
||||
Examples:
|
||||
|
||||
If I create an instance like this:
|
||||
|
||||
<iron-meta key="info" value="foo/bar"></iron-meta>
|
||||
|
||||
Note that value="foo/bar" is the metadata I've defined. I could define more
|
||||
attributes or use child nodes to define additional metadata.
|
||||
|
||||
Now I can access that element (and it's metadata) from any `iron-meta-query` instance:
|
||||
|
||||
var value = new Polymer.IronMetaQuery({key: 'info'}).value;
|
||||
|
||||
@group Polymer Iron Elements
|
||||
@element iron-meta-query
|
||||
*/
|
||||
Polymer.IronMetaQuery = Polymer({
|
||||
|
||||
is: 'iron-meta-query',
|
||||
|
||||
properties: {
|
||||
|
||||
/**
|
||||
* The type of meta-data. All meta-data of the same type is stored
|
||||
* together.
|
||||
*/
|
||||
type: {
|
||||
type: String,
|
||||
value: 'default',
|
||||
observer: '_typeChanged'
|
||||
},
|
||||
|
||||
/**
|
||||
* Specifies a key to use for retrieving `value` from the `type`
|
||||
* namespace.
|
||||
*/
|
||||
key: {
|
||||
type: String,
|
||||
observer: '_keyChanged'
|
||||
},
|
||||
|
||||
/**
|
||||
* The meta-data to store or retrieve.
|
||||
*/
|
||||
value: {
|
||||
type: Object,
|
||||
notify: true,
|
||||
readOnly: true
|
||||
},
|
||||
|
||||
/**
|
||||
* Array of all meta-data values for the given type.
|
||||
*/
|
||||
list: {
|
||||
type: Array,
|
||||
notify: true
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Actually a factory method, not a true constructor. Only runs if
|
||||
* someone invokes it directly (via `new Polymer.IronMeta()`);
|
||||
*/
|
||||
factoryImpl: function(config) {
|
||||
if (config) {
|
||||
for (var n in config) {
|
||||
switch(n) {
|
||||
case 'type':
|
||||
case 'key':
|
||||
this[n] = config[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
created: function() {
|
||||
// TODO(sjmiles): good for debugging?
|
||||
this._metaDatas = metaDatas;
|
||||
this._metaArrays = metaArrays;
|
||||
},
|
||||
|
||||
_keyChanged: function(key) {
|
||||
this._setValue(this._metaData && this._metaData[key]);
|
||||
},
|
||||
|
||||
_typeChanged: function(type) {
|
||||
this._metaData = metaDatas[type];
|
||||
this.list = metaArrays[type];
|
||||
if (this.key) {
|
||||
this._keyChanged(this.key);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves meta data value by key.
|
||||
*/
|
||||
byKey: function(key) {
|
||||
return this._metaData && this._metaData[key];
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
48
dashboard-ui/bower_components/iron-meta/test/basic.html
vendored
Normal file
48
dashboard-ui/bower_components/iron-meta/test/basic.html
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 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
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-meta-basic</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
|
||||
<link rel="import" href="../iron-meta.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<iron-meta key="info" value="foo/bar"></iron-meta>
|
||||
|
||||
<script>
|
||||
|
||||
suite('basic', function() {
|
||||
|
||||
test('byKey', function() {
|
||||
var meta = document.createElement('iron-meta');
|
||||
assert.equal(meta.byKey('info'), 'foo/bar');
|
||||
});
|
||||
|
||||
test('list', function() {
|
||||
var meta = document.createElement('iron-meta');
|
||||
assert.equal(meta.list.length, 1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
30
dashboard-ui/bower_components/iron-meta/test/index.html
vendored
Normal file
30
dashboard-ui/bower_components/iron-meta/test/index.html
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 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
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<title>Tests</title>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
WCT.loadSuites([
|
||||
'basic.html',
|
||||
'iron-meta.html'
|
||||
]);
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
186
dashboard-ui/bower_components/iron-meta/test/iron-meta.html
vendored
Normal file
186
dashboard-ui/bower_components/iron-meta/test/iron-meta.html
vendored
Normal file
|
@ -0,0 +1,186 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 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
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-meta</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
|
||||
<link rel="import" href="../iron-meta.html">
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="TrivialMeta">
|
||||
<template>
|
||||
<iron-meta self key="info"></iron-meta>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="ManyMetas">
|
||||
<template>
|
||||
<iron-meta self key="default1"></iron-meta>
|
||||
<iron-meta self key="default2"></iron-meta>
|
||||
<iron-meta self key="default3"></iron-meta>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="DifferentTypedMetas">
|
||||
<template>
|
||||
<iron-meta self type="foo" key="foobarKey"></iron-meta>
|
||||
<iron-meta self type="bar" key="foobarKey"></iron-meta>
|
||||
<iron-meta self key="defaultKey"></iron-meta>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="ClashingMetas">
|
||||
<template>
|
||||
<iron-meta self key="baz"></iron-meta>
|
||||
<iron-meta self key="baz"></iron-meta>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
suite('<iron-meta>', function () {
|
||||
suite('basic behavior', function () {
|
||||
var meta;
|
||||
|
||||
setup(function () {
|
||||
meta = fixture('TrivialMeta');
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
meta.key = null;
|
||||
});
|
||||
|
||||
test('uses itself as the default value', function () {
|
||||
expect(meta.value).to.be.equal(meta);
|
||||
});
|
||||
|
||||
test('can be assigned alternative values', function () {
|
||||
meta.value = 'foobar';
|
||||
|
||||
expect(meta.list[0]).to.be.equal('foobar');
|
||||
});
|
||||
|
||||
test('can access same-type meta values by key', function () {
|
||||
expect(meta.byKey(meta.key)).to.be.equal(meta.value);
|
||||
});
|
||||
|
||||
test('yields a list of same-type meta data', function () {
|
||||
expect(meta.list).to.be.ok;
|
||||
expect(meta.list.length).to.be.equal(1);
|
||||
expect(meta.list[0]).to.be.equal(meta);
|
||||
});
|
||||
});
|
||||
|
||||
suite('many same-typed metas', function () {
|
||||
var metas;
|
||||
|
||||
setup(function () {
|
||||
metas = fixture('ManyMetas');
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
metas.forEach(function (meta) {
|
||||
meta.key = null;
|
||||
});
|
||||
});
|
||||
|
||||
test('all cache all meta values', function () {
|
||||
metas.forEach(function (meta, index) {
|
||||
expect(meta.list.length).to.be.equal(metas.length);
|
||||
expect(meta.list[index].value).to.be.equal(meta.value);
|
||||
});
|
||||
});
|
||||
|
||||
test('can be unregistered individually', function () {
|
||||
metas[0].key = null;
|
||||
|
||||
expect(metas[0].list.length).to.be.equal(2);
|
||||
expect(metas[0].list).to.be.deep.equal([metas[1], metas[2]])
|
||||
});
|
||||
|
||||
test('can access each others value by key', function () {
|
||||
expect(metas[0].byKey('default2')).to.be.equal(metas[1].value);
|
||||
});
|
||||
});
|
||||
|
||||
suite('different-typed metas', function () {
|
||||
var metas;
|
||||
|
||||
setup(function () {
|
||||
metas = fixture('DifferentTypedMetas');
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
metas.forEach(function (meta) {
|
||||
meta.key = null;
|
||||
});
|
||||
});
|
||||
|
||||
test('cache their values separately', function () {
|
||||
var fooMeta = metas[0];
|
||||
var barMeta = metas[1];
|
||||
|
||||
expect(fooMeta.value).to.not.be.equal(barMeta.value);
|
||||
expect(fooMeta.byKey('foobarKey')).to.be.equal(fooMeta.value);
|
||||
expect(barMeta.byKey('foobarKey')).to.be.equal(barMeta.value);
|
||||
});
|
||||
|
||||
test('cannot access values of other types', function () {
|
||||
var defaultMeta = metas[2];
|
||||
|
||||
expect(defaultMeta.byKey('foobarKey')).to.be.equal(undefined);
|
||||
});
|
||||
|
||||
test('only list values of their type', function () {
|
||||
metas.forEach(function (meta) {
|
||||
expect(meta.list.length).to.be.equal(1);
|
||||
expect(meta.list[0]).to.be.equal(meta.value);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
suite('metas with clashing keys', function () {
|
||||
var metaPair;
|
||||
|
||||
setup(function () {
|
||||
metaPair = fixture('ClashingMetas');
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
metaPair.forEach(function (meta) {
|
||||
meta.key = null;
|
||||
});
|
||||
});
|
||||
|
||||
test('let the last value win registration against the key', function () {
|
||||
var registeredValue = metaPair[0].byKey(metaPair[0].key);
|
||||
var firstValue = metaPair[0].value;
|
||||
var secondValue = metaPair[1].value;
|
||||
|
||||
expect(registeredValue).to.not.be.equal(firstValue);
|
||||
expect(registeredValue).to.be.equal(secondValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue