Marko v3: Node#wrap --> Node#wrapWith

This commit is contained in:
Patrick Steele-Idem 2016-02-08 22:42:44 -07:00
parent 9282451b6b
commit 6d366ab1ee
3 changed files with 8 additions and 8 deletions

View File

@ -51,7 +51,7 @@ class Node {
this.on('afterGenerateCode', listener);
}
wrap(wrapperNode) {
wrapWith(wrapperNode) {
ok(this.container, 'Node does not belong to a container: ' + this);
var replaced = this.container.replaceChild(wrapperNode, this);
ok(replaced, 'Invalid state. Child does not belong to the container');

View File

@ -27,7 +27,7 @@ var coreAttrHandlers = [
//Surround the existing node with the newly created loop node
// NOTE: The loop node will be one of the following:
// ForEach, ForRange, ForEachProp or ForStatement
node.wrap(loopNode);
node.wrapWith(loopNode);
}
],
[
@ -38,7 +38,7 @@ var coreAttrHandlers = [
}
var ifNode = this.builder.ifStatement(ifArgument);
//Surround the existing node with an "If" node
node.wrap(ifNode);
node.wrapWith(ifNode);
}
],
[
@ -50,7 +50,7 @@ var coreAttrHandlers = [
ifArgument = this.builder.negate(ifArgument);
var ifNode = this.builder.ifStatement(ifArgument);
//Surround the existing node with an "if" node
node.wrap(ifNode);
node.wrapWith(ifNode);
}
],
[
@ -61,14 +61,14 @@ var coreAttrHandlers = [
}
var elseIfNode = this.builder.elseIfStatement(elseIfArgument);
//Surround the existing node with an "ElseIf" node
node.wrap(elseIfNode);
node.wrapWith(elseIfNode);
}
],
[
'else', function(attr, node) {
var elseNode = this.builder.elseStatement();
//Surround the existing node with an "Else" node
node.wrap(elseNode);
node.wrapWith(elseNode);
}
],
[

View File

@ -38,12 +38,12 @@ module.exports = function(compiler) {
enter(node) {
if (node.type === 'HtmlElement') {
if (node.hasAttribute('for')) {
node.wrap(forEach('color', 'data.colors'));
node.wrapWith(forEach('color', 'data.colors'));
node.removeAttribute('for');
}
if (node.hasAttribute('if')) {
node.wrap(ifStatement('notEmpty(data.colors)'));
node.wrapWith(ifStatement('notEmpty(data.colors)'));
node.removeAttribute('if');
}
}