4
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
Code distributed by Google as part of the polymer project is also
9
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
15
<title>iron-selector-selected-attribute</title>
16
<meta charset="utf-8">
17
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
19
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
20
<script src="../../web-component-tester/browser.js"></script>
21
<script src="../../test-fixture/test-fixture-mocha.js"></script>
23
<link rel="import" href="../../test-fixture/test-fixture.html">
24
<link rel="import" href="../iron-selector.html">
35
<test-fixture id="test">
37
<iron-selector id="selector">
47
<test-fixture id="test-attr-change">
49
<iron-selector id="selector" attr-for-selected="data-x" selected="x-1">
50
<div data-x="x-1" data-y="y-1">1</div>
51
<div data-x="x-2" data-y="y-2">2</div>
52
<div data-x="x-3" data-y="y-3">3</div>
57
<test-fixture id="test-attr-change-multi">
59
<iron-selector multi id="selector"
60
attr-for-selected="data-x"
61
selected-values='["x-1","x-2"]'>
62
<div data-x="x-1" data-y="y-1">1</div>
63
<div data-x="x-2" data-y="y-2">2</div>
64
<div data-x="x-3" data-y="y-3">3</div>
71
suite('selected attributes', function() {
79
test('custom selectedAttribute', function() {
80
// set selectedAttribute
81
s.selectedAttribute = 'myattr';
82
// check selected attribute (should not be there)
83
assert.isFalse(s.children[4].hasAttribute('myattr'));
86
// now selected attribute should be there
87
assert.isTrue(s.children[4].hasAttribute('myattr'));
92
suite('changing attrForSelected', function() {
97
s = fixture('test-attr-change');
100
test('changing selectedAttribute', function() {
102
s.attrForSelected = 'data-y';
103
assert.equal(s.selected, 'y-1');
108
suite('changing attrForSelected in multi', function() {
113
s = fixture('test-attr-change-multi');
116
test('changing selectedAttribute', function() {
118
s.attrForSelected = 'data-y';
119
assert.equal(s.selectedValues.length, 2);
120
assert.equal(s.selectedValues[0],'y-1');
121
assert.equal(s.selectedValues[1],'y-2');