From a7099ccaed059615ab28599d19ad2fa596141efd Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 8 Mar 2015 17:00:26 +0200 Subject: [PATCH] preserve !important rules fixes rodneyrehm/viewport-units-buggyfill#44 --- test.css | 4 ++++ viewport-units-buggyfill.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/test.css b/test.css index 0eaa28d..2a6b9b8 100755 --- a/test.css +++ b/test.css @@ -20,6 +20,10 @@ filter: progid:DXImageTransform.Microsoft.DropShadow(OffX=1vh, OffY=1vw, Color=#000000); } +.priority-important-test { + height: 20.3vh !important; +} + .use_css_content_hack-test { content: 'viewport-units-buggyfill; width: 80vmax; height: 80vmax;'; } diff --git a/viewport-units-buggyfill.js b/viewport-units-buggyfill.js index cdf7de7..93d594e 100755 --- a/viewport-units-buggyfill.js +++ b/viewport-units-buggyfill.js @@ -230,6 +230,11 @@ forEach.call(rule.style, function(name) { var value = rule.style.getPropertyValue(name); + // preserve those !important rules + if (rule.style.getPropertyPriority(name)) { + value += ' !important'; + } + viewportUnitExpression.lastIndex = 0; if (viewportUnitExpression.test(value)) { declarations.push([rule, name, value]);