Skip to content

Commit

Permalink
remove reference from API
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Jul 1, 2018
1 parent d7749e2 commit 3cc843c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 33 deletions.
30 changes: 14 additions & 16 deletions dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,11 @@

ifPortionsCode += separator + "function(locals){" + generate({
element: 0,
referenceElement: 1,
nextElement: 2,
nextElement: 1,
type: "Root",
attributes: [],
children: sibling.children
}) + "}({})";
}, ifReference) + "}({})";

separator = ",";
} else {
Expand Down Expand Up @@ -443,12 +442,11 @@
generateMount(forReference, parent.element, reference) +
setElement(forPortion, "function(locals){" + generate({
element: 0,
referenceElement: 1,
nextElement: 2,
nextElement: 1,
type: "Root",
attributes: [],
children: element.children
}) + "};") +
}, forReference) + "};") +
setElement(forPortions, "[];") +
setElement(forLocals, "[];"),

Expand Down Expand Up @@ -522,29 +520,29 @@
}
};

var generate = function (tree) {
var children = tree.children;
var generate = function (root, reference) {
var children = root.children;
var create = "";
var update = "";
var destroy = "";
for (var i = 0; i < children.length; i++) {
var generated = generateAll(children[i], tree, tree, tree.referenceElement);
var generated = generateAll(children[i], root, root, reference);

create += generated[0];
update += generated[1];
destroy += generated[2];
}

var prelude = "var " + (getElement(tree.element)) + "," + (getElement(tree.referenceElement));
for (var i$1 = tree.referenceElement + 1; i$1 < tree.nextElement; i$1++) {
var prelude = "var " + (getElement(root.element));
for (var i$1 = root.element + 1; i$1 < root.nextElement; i$1++) {
prelude += "," + getElement(i$1);
}

return (prelude + ";return [function(_0,_1){" + (setElement(tree.element, "_0;")) + (setElement(tree.referenceElement, "_1;")) + create + "},function(){" + update + "},function(){" + destroy + "}];");
return (prelude + ";return [function(_0){" + (setElement(root.element, "_0;")) + create + "},function(){" + update + "},function(){" + destroy + "}];");
};

var compile = function (input) {
return generate(parse(input));
return generate(parse(input), null);
};

var createElement$1 = function (type) { return document.createElement(type); };
Expand Down Expand Up @@ -646,8 +644,8 @@
df: directiveFor$1
};

var create = function(root, reference) {
this._view[0](root, reference);
var create = function(root) {
this._view[0](root);
this.emit("create");
};

Expand Down Expand Up @@ -791,7 +789,7 @@
var instanceComponent = component("", data);
var instance = new instanceComponent();

instance.create(root, null);
instance.create(root);
instance.update();

return instance;
Expand Down
2 changes: 1 addition & 1 deletion dist/moon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/compiler/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { parse } from "./parser/parser";
import { generate } from "./generator/generator";

export const compile = (input) => {
return generate(parse(input));
return generate(parse(input), null);
};
Loading

0 comments on commit 3cc843c

Please sign in to comment.