fix buildExternalHelpers whitelist not including underscored helpers - fixes #2940
This commit is contained in:
parent
28a13bd400
commit
a55f210c7f
@ -73,8 +73,26 @@ function buildVar(namespace, builder) {
|
||||
}
|
||||
|
||||
function buildHelpers(body, namespace, whitelist) {
|
||||
function shouldIgnore(name) {
|
||||
if (!whitelist) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for the raw name
|
||||
if (whitelist.indexOf(name) >= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// typeof -> _typeof
|
||||
if (name[0] === "_" && whitelist.indexOf(name.slice(1)) >= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
each(helpers.list, function (name) {
|
||||
if (whitelist && whitelist.indexOf(name) === -1) return;
|
||||
if (shouldIgnore(name)) return;
|
||||
|
||||
let key = t.identifier(t.toIdentifier(name));
|
||||
body.push(t.expressionStatement(
|
||||
|
||||
@ -387,5 +387,10 @@ suite("api", function () {
|
||||
assert.ok(script.indexOf("classCallCheck") === -1);
|
||||
assert.ok(script.indexOf("inherits") === -1);
|
||||
});
|
||||
|
||||
test("underscored", function () {
|
||||
var script = buildExternalHelpers(["typeof"]);
|
||||
assert.ok(script.indexOf("typeof") >= 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user