mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Marko v3: Node#wrap --> Node#wrapWith
This commit is contained in:
parent
9282451b6b
commit
6d366ab1ee
@ -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');
|
||||
|
||||
@ -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);
|
||||
}
|
||||
],
|
||||
[
|
||||
|
||||
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user