Skip to content

Commit

Permalink
Refresh cache'd styles contents in IE 10 and 11
Browse files Browse the repository at this point in the history
Fixes #3770
  • Loading branch information
dfreedm committed Jul 11, 2016
1 parent e579f58 commit 80be0df
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/style-properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
var matchesSelector = Polymer.DomApi.matchesSelector;
var styleUtil = Polymer.StyleUtil;
var styleTransformer = Polymer.StyleTransformer;
var IS_IE = navigator.userAgent.match('Trident');

var settings = Polymer.Settings;

Expand Down Expand Up @@ -493,6 +494,10 @@
}
element._customStyle = style;
}
// @media rules may be stale in IE 10 and 11
if (IS_IE) {
style.textContent = style.textContent;
}
return style;
},

Expand Down
82 changes: 82 additions & 0 deletions test/smoke/stale-ie-cache.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<head>
<script src="../../../webcomponentsjs/webcomponents-lite.min.js"></script>
<link href="../../polymer.html" rel="import">

<style>

@media (min-width: 800px) {
body {
background: red;
}
}

@media (max-width: 799px) {
body {
background: green;
}
}
</style>


</head>
<body>

<dom-module id="x-foo">
<template>
<style>

:host {
display: block;
margin-left: var(--foo, 0px);
}

.item {
width: 100px;
height: 100px;
border: 1px solid white;
}

@media (min-width: 800px) {
:host {
--foo: 10px;
}

.item {
background: red;
}
}

@media (max-width: 799px) {
.item {
background: green;
}
}

</style>

<div class="item"></div>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-foo'
});
});
var debouncer;
window.onresize = function() {
Polymer.Debounce(debouncer, function() {
Polymer.updateStyles();
}, 100);
};
</script>
</dom-module>


<h1>The box should match the background color</h1>

<x-foo></x-foo>

</body>
</html>

0 comments on commit 80be0df

Please sign in to comment.