Skip to content

Commit 6b2f8c6

Browse files
committed
Remove visibility hidden from veiling; add test for autofocus on input, fixes #317
1 parent 6004350 commit 6b2f8c6

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

src/boot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
var TRANSITION_TIME = 0.3;
1616
var style = document.createElement('style');
1717
style.textContent = '.' + VEILED_CLASS + ' { ' +
18-
'visibility: hidden; opacity: 0; } \n' +
18+
'opacity: 0; } \n' +
1919
'.' + UNVEIL_CLASS + '{ ' +
2020
'-webkit-transition: opacity ' + TRANSITION_TIME + 's; ' +
2121
'transition: opacity ' + TRANSITION_TIME +'s; }\n';

test/html/styling/unveil.html

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111
<script src="../../../../tools/test/htmltest.js"></script>
1212
<script src="../../../../tools/test/chai/chai.js"></script>
1313
<style>
14+
.polymer-veiled {
15+
background-color: white;
16+
}
17+
1418
.polymer-unveil {
15-
background: red;
19+
background-color: red;
20+
transition: all 0.3s;
21+
-webkit-transition: all 0.3s;
1622
}
1723
</style>
1824
<script>
@@ -30,17 +36,21 @@
3036
<script>
3137
Polymer('x-test', {
3238
enteredView: function() {
33-
chai.assert.isTrue(getComputedStyle(this).visibility == 'hidden',
34-
'veiled elements are visible');
39+
chai.assert.isTrue(getComputedStyle(this).opacity == '0',
40+
'veiled elements are not opacity 0');
3541
}
3642
});
3743
</script>
3844
</polymer-element>
3945

4046
<script>
47+
document.addEventListener('DOMContentLoaded', function() {
48+
chai.assert.isTrue(getComputedStyle(document.body).opacity == '0',
49+
'veiled elements are opacity 0');
50+
});
4151
document.addEventListener('WebComponentsReady', function() {
42-
chai.assert.isTrue(getComputedStyle(document.body).visibility == 'hidden',
43-
'veiled elements are visible');
52+
chai.assert.isTrue(getComputedStyle(document.body).opacity == '0',
53+
'veiled elements are opacity 0');
4454
// test during transition
4555
requestAnimationFrame(function() {
4656
requestAnimationFrame(function() {
@@ -49,24 +59,21 @@
4959
chai.assert.equal(document.querySelectorAll('.polymer-unveil').length, 3,
5060
'element unveil class is applied when unveiling');
5161
var nodes = document.querySelectorAll('.polymer-unveil')
52-
for (var i=0; i<nodes.length; i++) {
53-
chai.assert.equal(getComputedStyle(nodes[i]).backgroundColor,
54-
'rgb(255, 0, 0)', 'user unveil style is applied');
55-
}
56-
5762
});
5863
});
64+
var isDone;
5965
var endEvent = (document.documentElement.style.webkitTransition !== undefined) ?
6066
'webkitTransitionEnd' : 'transitionend';
6167
document.body.addEventListener(endEvent, function(e) {
62-
if (e.target != this) {
68+
if (e.target != this || isDone) {
6369
return;
6470
}
71+
isDone = true;
6572
requestAnimationFrame(function() {
6673
for (var i=0, l=Polymer.veiledElements.length, elt; i<l; i++) {
6774
elt = document.querySelector(Polymer.veiledElements[i]);
68-
chai.assert.isTrue(getComputedStyle(elt).visibility == 'visible',
69-
'unveiled elements are visible');
75+
chai.assert.isTrue(getComputedStyle(elt).opacity == '1',
76+
'unveiled elements are not opacity 0');
7077
}
7178
chai.assert.equal(document.querySelectorAll('.polymer-veiled').length, 0,
7279
'element classes are cleared after unveiling');

0 commit comments

Comments
 (0)