@@ -5,6 +5,29 @@ var gatherVariableDependencies = require('./gather-variable-dependencies');
55var findNodeAncestorWithSelector = require ( './find-node-ancestor-with-selector' ) ;
66var cloneSpliceParentOntoNodeWhen = require ( './clone-splice-parent-onto-node-when' ) ;
77
8+ /*
9+ Object.assign polyfill
10+ https://gist.github.com/WebReflection/10404826
11+ */
12+ if ( ! ( 'assign' in Object ) ) {
13+ Object . assign = function ( has ) {
14+ 'use strict' ;
15+ return assign ;
16+ function assign ( target , source ) {
17+ for ( var i = 1 ; i < arguments . length ; i ++ ) {
18+ copy ( target , arguments [ i ] ) ;
19+ }
20+ return target ;
21+ }
22+ function copy ( target , source ) {
23+ for ( var key in source ) {
24+ if ( has . call ( source , key ) ) {
25+ target [ key ] = source [ key ] ;
26+ }
27+ }
28+ }
29+ } ( { } . hasOwnProperty ) ;
30+ }
831
932
1033// var() = var( <custom-property-name> [, <any-value> ]? )
@@ -61,8 +84,14 @@ var resolveValue = function(decl, map, /*optional*/ignorePseudoScope, /*internal
6184 }
6285 } ) ;
6386
87+ var fallbackValue ;
88+ if ( fallback ) {
89+ var cloneDecl = Object . assign ( { } , decl , { value :fallback } ) ;
90+ fallbackValue = resolveValue ( cloneDecl , map , false , true ) . value ;
91+ }
92+
6493 // Default to the calculatedInPlaceValue which might be a previous fallback, then try this declarations fallback
65- var replaceValue = ( matchingVarDeclMapItem || { } ) . calculatedInPlaceValue || fallback ;
94+ var replaceValue = ( matchingVarDeclMapItem || { } ) . calculatedInPlaceValue || fallbackValue ;
6695 // Otherwise if the dependency health is good(no circular or self references), dive deeper and resolve
6796 if ( matchingVarDeclMapItem !== undefined && ! gatherVariableDependencies ( variablesUsedInValue , map ) . hasCircularOrSelfReference ) {
6897 // Splice the declaration parent onto the matching entry
0 commit comments