Skip to content

Instantly share code, notes, and snippets.

@mattn
Created June 9, 2016 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/3b5dd316d115eed376eb56d57be70a49 to your computer and use it in GitHub Desktop.
Save mattn/3b5dd316d115eed376eb56d57be70a49 to your computer and use it in GitHub Desktop.
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