@@ -22,22 +22,23 @@ tree.Media.prototype = {
2222 env . mediaBlocks = [ ] ;
2323 env . mediaPath = [ ] ;
2424 }
25-
26- env . mediaBlocks . push ( this ) ;
25+
26+ var blockIndex = env . mediaBlocks . length ;
2727 env . mediaPath . push ( this ) ;
28+ env . mediaBlocks . push ( this ) ;
2829
29- this . features = this . features . eval ( env ) ;
30- env . frames . unshift ( this ) ;
31- this . ruleset = this . ruleset . eval ( env ) ;
30+ var media = new ( tree . Media ) ( [ ] , [ ] ) ;
31+ media . features = this . features . eval ( env ) ;
32+
33+ env . frames . unshift ( this . ruleset ) ;
34+ media . ruleset = this . ruleset . eval ( env ) ;
3235 env . frames . shift ( ) ;
33-
36+
37+ env . mediaBlocks [ blockIndex ] = media ;
3438 env . mediaPath . pop ( ) ;
3539
36- if ( env . mediaPath . length === 0 ) {
37- return this . evalTop ( env ) ;
38- } else {
39- return this . evalNested ( env ) ;
40- }
40+ return env . mediaPath . length === 0 ? media . evalTop ( env ) :
41+ media . evalNested ( env )
4142 } ,
4243 variable : function ( name ) { return tree . Ruleset . prototype . variable . call ( this . ruleset , name ) } ,
4344 find : function ( ) { return tree . Ruleset . prototype . find . apply ( this . ruleset , arguments ) } ,
@@ -93,9 +94,9 @@ tree.Media.prototype = {
9394 return new ( tree . Ruleset ) ( [ ] , [ ] ) ;
9495 } ,
9596 permute : function ( arr ) {
96- if ( arr . length == 0 ) {
97+ if ( arr . length === 0 ) {
9798 return [ ] ;
98- } else if ( arr . length == 1 ) {
99+ } else if ( arr . length === 1 ) {
99100 return arr [ 0 ] ;
100101 } else {
101102 var result = [ ] ;
0 commit comments