Skip to content

Commit 80be0df

Browse files
committed
Refresh cache'd styles contents in IE 10 and 11
Fixes #3770
1 parent e579f58 commit 80be0df

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

src/lib/style-properties.html

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
var matchesSelector = Polymer.DomApi.matchesSelector;
2121
var styleUtil = Polymer.StyleUtil;
2222
var styleTransformer = Polymer.StyleTransformer;
23+
var IS_IE = navigator.userAgent.match('Trident');
2324

2425
var settings = Polymer.Settings;
2526

@@ -493,6 +494,10 @@
493494
}
494495
element._customStyle = style;
495496
}
497+
// @media rules may be stale in IE 10 and 11
498+
if (IS_IE) {
499+
style.textContent = style.textContent;
500+
}
496501
return style;
497502
},
498503

test/smoke/stale-ie-cache.html

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="../../../webcomponentsjs/webcomponents-lite.min.js"></script>
5+
<link href="../../polymer.html" rel="import">
6+
7+
<style>
8+
9+
@media (min-width: 800px) {
10+
body {
11+
background: red;
12+
}
13+
}
14+
15+
@media (max-width: 799px) {
16+
body {
17+
background: green;
18+
}
19+
}
20+
</style>
21+
22+
23+
</head>
24+
<body>
25+
26+
<dom-module id="x-foo">
27+
<template>
28+
<style>
29+
30+
:host {
31+
display: block;
32+
margin-left: var(--foo, 0px);
33+
}
34+
35+
.item {
36+
width: 100px;
37+
height: 100px;
38+
border: 1px solid white;
39+
}
40+
41+
@media (min-width: 800px) {
42+
:host {
43+
--foo: 10px;
44+
}
45+
46+
.item {
47+
background: red;
48+
}
49+
}
50+
51+
@media (max-width: 799px) {
52+
.item {
53+
background: green;
54+
}
55+
}
56+
57+
</style>
58+
59+
<div class="item"></div>
60+
</template>
61+
<script>
62+
HTMLImports.whenReady(function() {
63+
Polymer({
64+
is: 'x-foo'
65+
});
66+
});
67+
var debouncer;
68+
window.onresize = function() {
69+
Polymer.Debounce(debouncer, function() {
70+
Polymer.updateStyles();
71+
}, 100);
72+
};
73+
</script>
74+
</dom-module>
75+
76+
77+
<h1>The box should match the background color</h1>
78+
79+
<x-foo></x-foo>
80+
81+
</body>
82+
</html>

0 commit comments

Comments
 (0)