Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Use better wrapper param names
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Feb 3, 2017
1 parent 234206e commit f50937a
Show file tree
Hide file tree
Showing 31 changed files with 79 additions and 79 deletions.
10 changes: 5 additions & 5 deletions src/helpers/extract-expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import isLiteralOrSpecial, { isLiteralOrSpecialNode } from "./is-literal-or-spec
import last from "./last";
import * as t from "babel-types";

function addClosureVar(expression, closureVars) {
function addClosureVar(expression, closureVars, defaultName) {
const init = expression.node;
const id = expression.scope.generateUidIdentifierBasedOnNode(init);
const id = expression.scope.generateUidIdentifierBasedOnNode(init, defaultName);

closureVars.push({ id, init });
return id;
Expand Down Expand Up @@ -74,7 +74,7 @@ const expressionExtractor = {
JSXSpreadAttribute(path) {
const { closureVarsStack } = this;
const argument = path.get("argument");
const id = addClosureVar(argument, last(closureVarsStack));
const id = addClosureVar(argument, last(closureVarsStack), "spread");
argument.replaceWith(id)
},

Expand All @@ -89,7 +89,7 @@ const expressionExtractor = {

// Only call defer JSX Children Expressions
if (!path.parentPath.isJSXElement()) {
expression.replaceWith(addClosureVar(expression, closureVars));
expression.replaceWith(addClosureVar(expression, closureVars, path.parentPath.node.name.name));
return;
}

Expand All @@ -105,7 +105,7 @@ const expressionExtractor = {

// Exit early if there's nothing to defer.
if (deferred.length === 0) {
expression.replaceWith(addClosureVar(expression, closureVars));
expression.replaceWith(addClosureVar(expression, closureVars, "child"));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var _jsxWrapper = function _jsxWrapper(func, args) {
};
};

var _span$wrapper = function _span$wrapper(_ref) {
return elementVoid("span", null, null, "attr", _ref);
var _span$wrapper = function _span$wrapper(_attr) {
return elementVoid("span", null, null, "attr", _attr);
};

function render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ var _renderArbitrary = function _renderArbitrary(child) {
}
};

var _span$wrapper = function _span$wrapper(_ref) {
var _span$wrapper = function _span$wrapper(_child) {
elementOpen("span");

_renderArbitrary(_ref);
_renderArbitrary(_child);

return elementClose("span");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _span$statics = ["key", ""],
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li");
elementOpen("span", _file$name, (_span$statics[1] = _file$name, _span$statics), "file", _file, "onclick", _ref);
elementOpen("span", _file$name, (_span$statics[1] = _file$name, _span$statics), "file", _file, "onclick", _onclick);

_renderArbitrary(_file$name2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ var _renderArbitrary = function _renderArbitrary(child) {
}
};

var _div$wrapper = function _div$wrapper(_deferred, _b, _deferred2, _b2, _ref, _ref2, _deferred3, _b3, _deferred4, _b4, _deferred5, _b5, _deferred6, _b6) {
var _div$wrapper = function _div$wrapper(_deferred, _b, _deferred2, _b2, _child, _child2, _deferred3, _b3, _deferred4, _b4, _deferred5, _b5, _deferred6, _b6) {
elementOpen("div");

_renderArbitrary(_b == 0 ? _deferred : _deferred());

_renderArbitrary(_b2 == 0 ? _deferred2 : _deferred2());

_renderArbitrary(_ref);
_renderArbitrary(_child);

_renderArbitrary(_ref2);
_renderArbitrary(_child2);

_renderArbitrary(_b3 == 0 ? _deferred3 : _deferred3());

Expand Down
14 changes: 7 additions & 7 deletions test/fixtures/eager-expressions/non-root/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ var _renderArbitrary = function _renderArbitrary(child) {
}
};

var _test$wrapper = function _test$wrapper(_ref, _ref2, _ref3, _ref4, _ref5, _ref6) {
elementOpen("div", null, null, "attr", _ref);
elementOpen("div", null, null, "first", _ref2);
var _test$wrapper = function _test$wrapper(_attr, _first, _child, _child2, _second, _child3) {
elementOpen("div", null, null, "attr", _attr);
elementOpen("div", null, null, "first", _first);

_renderArbitrary(_ref3);
_renderArbitrary(_child);

elementClose("div");

_renderArbitrary(_ref4);
_renderArbitrary(_child2);

elementOpen("div", null, null, "second", _ref5);
elementOpen("div", null, null, "second", _second);

_renderArbitrary(_ref6);
_renderArbitrary(_child3);

elementClose("div");
return elementClose("div");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ var _map$wrapper = function _map$wrapper(_i) {

return elementClose("map");
},
_div$wrapper = function _div$wrapper(_ref, _ref2) {
elementOpen("div", null, null, "first", _ref);
_div$wrapper = function _div$wrapper(_first, _child) {
elementOpen("div", null, null, "first", _first);

_renderArbitrary(_ref2);
_renderArbitrary(_child);

return elementClose("div");
};
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/expression-children/14/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ var _renderArbitrary = function _renderArbitrary(child) {
}
};

var _span$wrapper = function _span$wrapper(_i, _ref, _i2) {
var _span$wrapper = function _span$wrapper(_i, _child, _i2) {
elementOpen("span", null, null, "attr", _i);

_renderArbitrary(_ref);
_renderArbitrary(_child);

_renderArbitrary(_i2);

Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/expression-children/9/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ var _renderArbitrary = function _renderArbitrary(child) {
}
};

var _one$wrapper = function _one$wrapper(_ref) {
var _one$wrapper = function _one$wrapper(_child) {
elementOpen("one");

_renderArbitrary(_ref);
_renderArbitrary(_child);

return elementClose("one");
},
_two$wrapper = function _two$wrapper(_ref2) {
_two$wrapper = function _two$wrapper(_child2) {
elementOpen("two");

_renderArbitrary(_ref2);
_renderArbitrary(_child2);

return elementClose("two");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _li$statics = ["key", ""],
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _ref);
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _onclick);

_renderArbitrary(_file$name2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _li$statics = ["key", ""],
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _ref);
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _onclick);

_renderArbitrary(_file$name2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _li$statics = ["key", ""],
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _ref);
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _onclick);

_renderArbitrary(_file$name2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _li$statics = ["key", ""],
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _ref);
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _onclick);

_renderArbitrary(_file$name2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _li$statics = ["key", ""],
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _ref);
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _onclick);

_renderArbitrary(_file$name2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _span$statics = ["key", ""],
_span$wrapper = function _span$wrapper(_file$name3, _file2, _ref2, _file$name4) {
elementOpen("span", _file$name3, (_span$statics[1] = _file$name3, _span$statics), "file", _file2, "onclick", _ref2);
_span$wrapper = function _span$wrapper(_file$name3, _file2, _onclick2, _file$name4) {
elementOpen("span", _file$name3, (_span$statics[1] = _file$name3, _span$statics), "file", _file2, "onclick", _onclick2);

_renderArbitrary(_file$name4);

return elementClose("span");
},
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
elementOpen("li", null, null, "attr", _jsxWrapper(_span$wrapper, [_file$name, _file, _ref, _file$name2]));
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li", null, null, "attr", _jsxWrapper(_span$wrapper, [_file$name, _file, _onclick, _file$name2]));
return elementClose("li");
};

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/fast-root/true/attribute/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _li$statics = ["key", ""],
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _ref);
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _onclick);

_renderArbitrary(_file$name2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _span$statics = ["key", ""],
_span$wrapper = function _span$wrapper(_file$name3, _file2, _ref2, _file$name4) {
_span$wrapper = function _span$wrapper(_file$name3, _file2, _onclick2, _file$name4) {
elementOpen("span");
elementOpen("span", _file$name3, (_span$statics[1] = _file$name3, _span$statics), "file", _file2, "onclick", _ref2);
elementOpen("span", _file$name3, (_span$statics[1] = _file$name3, _span$statics), "file", _file2, "onclick", _onclick2);

_renderArbitrary(_file$name4);

elementClose("span");
return elementClose("span");
},
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
elementOpen("li", null, null, "attr", _jsxWrapper(_span$wrapper, [_file$name, _file, _ref, _file$name2]));
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li", null, null, "attr", _jsxWrapper(_span$wrapper, [_file$name, _file, _onclick, _file$name2]));
return elementClose("li");
};

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/fast-root/true/nested-attribute/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _span$statics = ["key", ""],
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li");
elementOpen("span", _file$name, (_span$statics[1] = _file$name, _span$statics), "file", _file, "onclick", _ref);
elementOpen("span", _file$name, (_span$statics[1] = _file$name, _span$statics), "file", _file, "onclick", _onclick);

_renderArbitrary(_file$name2);

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/fast-root/true/secondary-element/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ var _ul$wrapper = function _ul$wrapper(_deferred, _args) {
return elementClose("ul");
},
_li$statics = ["key", ""],
_li$wrapper = function _li$wrapper(_file$name, _file, _ref, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _ref);
_li$wrapper = function _li$wrapper(_file$name, _file, _onclick, _file$name2) {
elementOpen("li", _file$name, (_li$statics[1] = _file$name, _li$statics), "file", _file, "onclick", _onclick);

_renderArbitrary(_file$name2);

Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/inline-expressions/eager-children/expected.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function render() {
var i = 0;
var _ref = i++,
_ref2 = i++;
var _attr = i++,
_other = i++;
elementOpen("root", null, null, "attr", i++);
elementVoid("div", null, null, "attr", _ref, "other", _ref2);
elementVoid("div", null, null, "attr", _attr, "other", _other);
return elementClose("root");
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ var _jsxWrapper = function _jsxWrapper(func, args) {
};
};

var _div$wrapper = function _div$wrapper(_ref) {
return elementVoid("div", null, null, "attr", _ref);
var _div$wrapper = function _div$wrapper(_attr) {
return elementVoid("div", null, null, "attr", _attr);
},
_div$statics = ["key", ""];

function render() {
var _attr, _div$key;
var _attr2, _div$key;

_attr = _jsxWrapper(_div$wrapper, [i++]);
return elementVoid("div", _div$key = i++, (_div$statics[1] = _div$key, _div$statics), "attr2", _attr);
_attr2 = _jsxWrapper(_div$wrapper, [i++]);
return elementVoid("div", _div$key = i++, (_div$statics[1] = _div$key, _div$statics), "attr2", _attr2);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ function render() {

elementOpenEnd("div");
return elementClose("div");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _div$statics = ["key", ""],
_div$wrapper = function _div$wrapper(_ref, _ref2, _ref3) {
elementOpen("div", null, null, "attr", _ref);
elementVoid("div", _ref3, (_div$statics[1] = _ref3, _div$statics), "attr2", _ref2);
_div$wrapper = function _div$wrapper(_attr, _attr2, _key) {
elementOpen("div", null, null, "attr", _attr);
elementVoid("div", _key, (_div$statics[1] = _key, _div$statics), "attr2", _attr2);
return elementClose("div");
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ var _renderArbitrary = function _renderArbitrary(child) {
};

var _div$statics = ["key", ""],
_div$wrapper = function _div$wrapper(_ref, _obj, _ref2) {
elementOpen("div", null, null, "attr", _ref);
elementVoid("div", _ref2, (_div$statics[1] = _ref2, _div$statics), "spread", _obj);
_div$wrapper = function _div$wrapper(_attr, _obj, _key) {
elementOpen("div", null, null, "attr", _attr);
elementVoid("div", _key, (_div$statics[1] = _key, _div$statics), "spread", _obj);
return elementClose("div");
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ var todoItems = items.map(function (x) {
_renderArbitrary(todoItems);

return (0, _idomWrapper.elementClose)("div");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ iDOM.patch(container, function () {
_renderArbitrary(todoItems);

return (0, _idomWrapper.elementClose)("div");
});
});
2 changes: 1 addition & 1 deletion test/fixtures/patch-root/object/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Component.prototype.template = function (data) {

Component.prototype.render = function () {
(0, _incrementalDom.patch)(this.element, this.template, this.data);
};
};
2 changes: 1 addition & 1 deletion test/fixtures/patch-root/requires-root-node/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ function todoItems() {

(0, _incrementalDom.patch)(container, function () {
todoItems();
});
});
Loading

0 comments on commit f50937a

Please sign in to comment.