Skip to content

Commit 8f2b331

Browse files
committed
Merge pull request #3485 from Polymer/dom-bind-loading
Ensure that dom-bind always waits until DOMContentLoaded to render.
2 parents 8f4c3f6 + 44d06f1 commit 8f2b331

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

src/lib/template/dom-bind.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@
6969
// have resolved
7070
var self = this;
7171
Polymer.RenderStatus.whenReady(function() {
72-
self._markImportsReady();
72+
if (document.readyState == 'loading') {
73+
document.addEventListener('DOMContentLoaded', function() {
74+
self._markImportsReady();
75+
});
76+
} else {
77+
self._markImportsReady();
78+
}
7379
});
7480
},
7581

test/runner.html

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
'unit/dom-if.html',
7070
'unit/dom-template.html',
7171
'unit/dom-bind.html',
72+
'unit/dom-bind-yield.html',
7273
'unit/script-after-import-in-head.html',
7374
'unit/globals.html'
7475
];

test/unit/dom-bind-yield.html

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!doctype html>
2+
<!--
3+
@license
4+
Copyright (c) 2014 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
10+
-->
11+
<html>
12+
<head>
13+
<meta charset="utf-8">
14+
<script src="../../../web-component-tester/browser.js"></script>
15+
</head>
16+
<body>
17+
18+
<link rel="import" href="../../polymer.html">
19+
20+
<script>
21+
if (window.Polymer) {
22+
Polymer({
23+
is: 'x-fire',
24+
ready: function() {
25+
this.fire('fired');
26+
}
27+
})
28+
}
29+
</script>
30+
31+
<template is="dom-bind" id="domBind">
32+
<x-fire on-fired="fired"></x-fire>
33+
</template>
34+
35+
<script>
36+
if (window.Polymer) {
37+
var now = Date.now() + 1000;
38+
while (Date.now() < now) {
39+
Math.random();
40+
}
41+
}
42+
</script>
43+
44+
<script>
45+
window.domBind.fired = function() {
46+
this.didFire = true;
47+
}
48+
</script>
49+
50+
<script>
51+
52+
if (window.Polymer) {
53+
54+
suite('bind stamps after page fully loads (despite yielding)', function() {
55+
56+
test('event handled', function() {
57+
assert.isTrue(window.domBind.didFire);
58+
});
59+
60+
});
61+
62+
}
63+
64+
</script>
65+
</body>
66+
</html>

0 commit comments

Comments
 (0)