OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
9 --> | 9 --> |
10 | 10 |
11 <html> | 11 <html> |
12 <head> | 12 <head> |
13 | 13 |
14 <title>iron-media-query-basic</title> | 14 <title>iron-media-query-basic</title> |
15 <meta charset="utf-8"> | 15 <meta charset="utf-8"> |
16 <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 16 <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
17 | 17 |
18 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> | 18 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
19 <script src="../../web-component-tester/browser.js"></script> | 19 <script src="../../web-component-tester/browser.js"></script> |
20 <script src="../../test-fixture/test-fixture-mocha.js"></script> | |
21 | |
22 <link rel="import" href="../iron-media-query.html"> | 20 <link rel="import" href="../iron-media-query.html"> |
23 <link rel="import" href="../../test-fixture/test-fixture.html"> | 21 |
24 | |
25 </head> | 22 </head> |
26 <body> | 23 <body> |
27 | 24 |
28 <test-fixture id="basic"> | 25 <test-fixture id="basic"> |
29 <template> | 26 <template> |
30 <iron-media-query></iron-media-query> | 27 <iron-media-query></iron-media-query> |
31 </template> | 28 </template> |
32 </test-fixture> | 29 </test-fixture> |
33 | 30 |
34 <script> | 31 <script> |
(...skipping 19 matching lines...) Expand all Loading... |
54 test('small max-width value', function() { | 51 test('small max-width value', function() { |
55 mq.query = '(max-width: 1px)'; | 52 mq.query = '(max-width: 1px)'; |
56 assert.equal(mq.queryMatches, false); | 53 assert.equal(mq.queryMatches, false); |
57 }); | 54 }); |
58 | 55 |
59 test('large max-width value', function() { | 56 test('large max-width value', function() { |
60 mq.query = '(max-width: 10000px)'; | 57 mq.query = '(max-width: 10000px)'; |
61 assert.equal(mq.queryMatches, true); | 58 assert.equal(mq.queryMatches, true); |
62 }); | 59 }); |
63 | 60 |
| 61 test('automatically wrap with parens', function() { |
| 62 mq.query = 'min-width: 1px'; |
| 63 assert.equal(mq.queryMatches, true); |
| 64 }); |
| 65 |
| 66 suite('`full` attribute', function() { |
| 67 test('media features without wrapping parentheses no longer match',
function() { |
| 68 mq.full = true; |
| 69 mq.query = 'min-width: 1px'; |
| 70 assert.equal(mq.queryMatches, false); |
| 71 }); |
| 72 |
| 73 test('media queries with both types and features match', function()
{ |
| 74 mq.full = true; |
| 75 mq.query = 'all and (min-width: 1px)'; |
| 76 assert.equal(mq.queryMatches, true); |
| 77 }); |
| 78 }); |
| 79 |
| 80 suite('query does not activate on empty string or null', function() { |
| 81 |
| 82 test('empty string', function() { |
| 83 mq.query = ''; |
| 84 assert.notOk(mq._mq); |
| 85 }); |
| 86 |
| 87 test('null', function() { |
| 88 mq.query = null; |
| 89 assert.notOk(mq._mq); |
| 90 }); |
| 91 |
| 92 }); |
| 93 |
| 94 test('media query destroys on detach', function() { |
| 95 mq.query = '(max-width: 800px)'; |
| 96 mq.parentNode.removeChild(mq); |
| 97 Polymer.dom.flush(); |
| 98 assert.notOk(mq._mq); |
| 99 }); |
| 100 |
| 101 test('media query re-enables on attach', function() { |
| 102 mq.query = '(max-width: 800px)'; |
| 103 var parent = mq.parentNode; |
| 104 parent.removeChild(mq); |
| 105 Polymer.dom.flush(); |
| 106 parent.appendChild(mq); |
| 107 Polymer.dom.flush(); |
| 108 assert.ok(mq._mq); |
| 109 }); |
| 110 |
64 }); | 111 }); |
65 | 112 |
66 }); | 113 }); |
67 | 114 |
68 </script> | 115 </script> |
69 | 116 |
70 </body> | 117 </body> |
71 </html> | 118 </html> |
OLD | NEW |