|
10 | 10 |
|
11 | 11 | var undefined;
|
12 | 12 |
|
13 |
| - window.react = { |
| 13 | + var react = { |
14 | 14 |
|
15 | 15 | nodes: {},
|
16 | 16 |
|
|
113 | 113 | for(var whichDirective = 0; whichDirective < directives.length; whichDirective++){
|
114 | 114 | if(eachAncestor === node && (directiveIndex||0) <= whichDirective){ break; }
|
115 | 115 | if(!lastLink){ continue; }
|
116 |
| - lastLink = this._extendScopeChainBasedOnDirective(lastLink, directives[whichDirective]); |
| 116 | + var directiveName = directives[whichDirective].shift(); |
| 117 | + if(this._extendScopeChainBasedOnDirective[directiveName]){ |
| 118 | + lastLink = this._extendScopeChainBasedOnDirective[directiveName](lastLink, directives[whichDirective]); |
| 119 | + } |
117 | 120 | }
|
118 | 121 | }
|
119 | 122 | return lastLink;
|
120 | 123 | },
|
121 | 124 |
|
122 |
| - // given a scope chain and a directive, extends the scope chain if necessary |
123 |
| - // does not operate on anchor directives |
124 |
| - _extendScopeChainBasedOnDirective: function(lastLink, directive){ |
125 |
| - // todo: turn these into named methods rather than a switch statement |
126 |
| - switch(directive[0]){ |
127 |
| - case 'within': |
128 |
| -//todo: test that this isn't broken - it used to not do a lookup, only checked the last scope |
129 |
| -//todo: deprecate the suppressObservers flag |
130 |
| - return this._extendScopeChain(lastLink, this._lookupInScopeChain(directive[1], lastLink, {suppressObservers: true}), {type:'within', key: directive[1]}); |
131 |
| - break; |
132 |
| -//todo: finish refactoring from here. asdf; |
133 |
| - case 'withinItem': |
134 |
| -// todo: write a test this for inadvertent fallthrough, as if it still said this._lookupInScopeChain(directive[1], lastLink, {suppressObservers: true}) |
135 |
| - return this._extendScopeChain(lastLink, this.scopeChain.scope[directive[1]], {type:'withinItem', key: directive[1]}); //todo: changed from type:'within' - will that break anything? |
136 |
| - break; |
137 |
| - case 'bindItem': |
138 |
| - var itemBindings = {}; |
139 |
| - if(directive.length === 4){ |
140 |
| - itemBindings[directive[2]] = directive[1]; |
141 |
| - } |
142 |
| - itemBindings[js.last(directive)] = new this._Fallthrough(directive[1]); |
143 |
| - return this._extendScopeChain(lastLink, itemBindings, {type:'itemBindings', key:directive[1]}); |
144 |
| - break; |
145 |
| - default: |
146 |
| - return lastLink; |
147 |
| - break; |
148 |
| - } |
149 |
| - }, |
150 |
| - |
151 | 125 | _buildScopeChainFromAnchorNames: function(names, lastLink){
|
152 | 126 | if(names){
|
153 | 127 | for(var whichToken = 1; whichToken < names.length; whichToken++){
|
|
485 | 459 | };
|
486 | 460 |
|
487 | 461 |
|
| 462 | + // given a scope chain and a directive, extends the scope chain if necessary |
| 463 | + // does not operate on anchor directives |
| 464 | + react._extendScopeChainBasedOnDirective = js.create(react, { |
| 465 | + within: function(lastLink, args){ |
| 466 | + //todo: test that this isn't broken - it used to not do a lookup, only checked the last scope |
| 467 | + //todo: deprecate the suppressObservers flag |
| 468 | + return this._extendScopeChain(lastLink, this._lookupInScopeChain(args[0], lastLink, {suppressObservers: true}), {type:'within', key: args[0]}); |
| 469 | + }, |
| 470 | + withinItem: function(lastLink, args){ |
| 471 | + // todo: write a test this for inadvertent fallthrough, as if it still said this._lookupInScopeChain(args[0], lastLink, {suppressObservers: true}) |
| 472 | + return this._extendScopeChain(lastLink, this.scopeChain.scope[args[0]], {type:'withinItem', key: args[0]}); //todo: changed from type:'within' - will that break anything? |
| 473 | + }, |
| 474 | + bindItem: function(lastLink, args){ |
| 475 | + var itemBindings = {}; |
| 476 | + if(args.length === 3){ |
| 477 | + itemBindings[args[1]] = args[0]; |
| 478 | + } |
| 479 | + itemBindings[js.last(args)] = new this._Fallthrough(args[0]); |
| 480 | + return this._extendScopeChain(lastLink, itemBindings, {type:'itemBindings', key:args[0]}); |
| 481 | + } |
| 482 | + }), |
| 483 | + |
488 | 484 | react.commands = js.create(react, {
|
489 | 485 |
|
490 | 486 | /*
|
|
672 | 668 |
|
673 | 669 | });
|
674 | 670 |
|
| 671 | + window.react = react; |
| 672 | + |
675 | 673 | }());
|
0 commit comments