Skip to content

Commit

Permalink
fix: optimize on m-ifs next to each other
Browse files Browse the repository at this point in the history
- they will both be replaced by text, not each other (like m-else, which needs to be deoptimized)
  • Loading branch information
kbrsh committed Sep 2, 2017
1 parent c23e577 commit d26dd24
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 49 deletions.
20 changes: 4 additions & 16 deletions dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@
var nodePropValue = nodeProps[vnodePropName];

if((vnodePropValue !== false) && (nodePropValue === undefined || vnodePropValue !== nodePropValue)) {
if(vnodePropName.length === 10 && vnodePropName === "xlink:href") {
if(vnodePropName === "xlink:href") {
node.setAttributeNS('http://www.w3.org/1999/xlink', "href", vnodePropValue);
} else {
node.setAttribute(vnodePropName, vnodePropValue === true ? '' : vnodePropValue);
Expand Down Expand Up @@ -2135,8 +2135,6 @@
if(typeof child !== "string") {
var data = prop.data;
var attrs = child.props;
var ifChild = (void 0);
var elseNode = (void 0);

if(attrs["m-else"] !== undefined) {
data.elseNode = [i, child];
Expand All @@ -2146,15 +2144,6 @@
state.dynamic = true;
data.ifSetDynamic = true;
}
} else if((ifChild = attrs["m-if"]) !== undefined) {
if(state.dynamic === false) {
if(data.ifSetDynamic === true) {
delete data.ifSetDynamic;
}

state.dynamic = true;
ifChild.data.ifSetDynamic = true;
}
}

break;
Expand All @@ -2171,10 +2160,9 @@

if(elseNode !== undefined) {
elseValue = generateNode(elseNode[1], parentNode, elseNode[0], state);
}

if(data.ifSetDynamic === true) {
state.dynamic = false;
if(data.ifSetDynamic === true) {
state.dynamic = false;
}
}

return (value + " ? " + code + " : " + elseValue);
Expand Down
Loading

0 comments on commit d26dd24

Please sign in to comment.