Skip to content

Commit

Permalink
Put getInitialValueForProperty on ApplyShim
Browse files Browse the repository at this point in the history
Can be overriden for build
Add comments to skipped tests on IE
  • Loading branch information
dfreedm committed Jul 29, 2016
1 parent 63c3bfb commit 0489ccf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/lib/apply-shim.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,13 @@
return mixinMap[name];
}

var measureElement;
function getInitialValueForProperty(property) {
if (!measureElement) {
measureElement = document.createElement('meta');
measureElement.style.all = 'initial';
document.head.appendChild(measureElement);
}
return window.getComputedStyle(measureElement).getPropertyValue(property);
}

function replaceInitialOrInherit(property, value) {
var match = INITIAL_INHERIT.exec(value);
if (match) {
if (match[1]) {
// initial
// replace `initial` with the concrete initial value for this property
value = getInitialValueForProperty(property);
value = ApplyShim._getInitialValueForProperty(property);
} else {
// inherit
// with this purposfully illegal value, the variable will be invalid at
Expand Down Expand Up @@ -294,6 +284,7 @@
}

var ApplyShim = {
_measureElement: null,
_map: mixinMap,
_separator: MIXIN_VAR_SEP,
transform: function(styles, elementProto) {
Expand All @@ -318,6 +309,14 @@
cssText = cssText.replace(VAR_ASSIGN, produceCssProperties);
// consume mixins
return consumeCssProperties(cssText);
},
_getInitialValueForProperty: function(property) {
if (!this._measureElement) {
this._measureElement = document.createElement('meta');
this._measureElement.style.all = 'initial';
document.head.appendChild(this._measureElement);
}
return window.getComputedStyle(this._measureElement).getPropertyValue(property);
}
};

Expand Down
2 changes: 2 additions & 0 deletions test/unit/styling-cross-scope-apply.html
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@
});

test('Mixins can set "inherit" for a property', function() {
// IE does not support `inherit` as a property value;
if (navigator.userAgent.match(/Trident/)) {
this.skip();
}
Expand All @@ -896,6 +897,7 @@
});

test('Mixins can set "initial" for a property', function() {
// IE does not support `initial` as a property value;
if (navigator.userAgent.match(/Trident/)) {
this.skip();
}
Expand Down

0 comments on commit 0489ccf

Please sign in to comment.