Created
June 9, 2016 08:51
-
-
Save mattn/3b5dd316d115eed376eb56d57be70a49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/sj.js b/src/sj.js | |
index 85e8e7b..9643c96 100644 | |
--- a/src/sj.js | |
+++ b/src/sj.js | |
@@ -35,16 +35,17 @@ | |
} | |
class ForRenderer { | |
- constructor(renderer, element, scope, varName) { | |
+ constructor(renderer, element, items, scope, varName) { | |
this.renderer = renderer; | |
this.element = element; | |
+ this.items = items; | |
this.scope = scope; | |
this.varName = varName; | |
} | |
render() { | |
let i = 0; | |
- for (const item of this.scope) { | |
+ for (const item of this.items) { | |
const currentScope = Object.assign({}, this.scope); | |
currentScope[this.varName] = item; | |
currentScope['$index'] = i++; | |
@@ -195,7 +196,7 @@ | |
const e = elem.querySelector('*'); | |
forRenderer = new ForRenderer((elem, scope) => { | |
this.renderDOM(elem, scope) | |
- }, e, scope[container], varName); | |
+ }, e, scope[container], scope, varName); | |
} | |
} else { | |
const labelValue = this.replaceVariables(attr.value, scope); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment