Remove tagged template literal global caching (#7722)

* Remove tagged template literal global caching

Fixes #7350.

* Review comments

* assert output
This commit is contained in:
Justin Ridgewell
2018-04-13 11:51:00 -04:00
committed by GitHub
parent 7a106025ea
commit 29eafbbf44
6 changed files with 73 additions and 38 deletions

View File

@@ -0,0 +1,15 @@
var tag = v => v;
function foo() {
return tag`some template`;
}
function bar() {
return tag`some template`;
}
expect(foo()).toBe(foo());
expect(foo()).toEqual(["some template"]);
expect(bar()).toBe(bar());
expect(bar()).toEqual(["some template"]);
expect(bar()).not.toBe(foo());

View File

@@ -0,0 +1,15 @@
var tag = v => v;
function foo() {
return tag`some template`;
}
function bar() {
return tag`some template`;
}
expect(foo()).toBe(foo());
expect(foo()).toEqual(["some template"]);
expect(bar()).toBe(bar());
expect(bar()).toEqual(["some template"]);
expect(bar()).not.toBe(foo());

View File

@@ -0,0 +1,20 @@
var _templateObject = /*#__PURE__*/ _taggedTemplateLiteral(["some template"]),
_templateObject2 = /*#__PURE__*/ _taggedTemplateLiteral(["some template"]);
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
var tag = v => v;
function foo() {
return tag(_templateObject);
}
function bar() {
return tag(_templateObject2);
}
expect(foo()).toBe(foo());
expect(foo()).toEqual(["some template"]);
expect(bar()).toBe(bar());
expect(bar()).toEqual(["some template"]);
expect(bar()).not.toBe(foo());

View File

@@ -4,7 +4,8 @@ var _templateObject = /*#__PURE__*/ _taggedTemplateLiteral([void 0], ["\\unicode
_templateObject4 = /*#__PURE__*/ _taggedTemplateLiteral(["left", void 0], ["left", "\\xg"]),
_templateObject5 = /*#__PURE__*/ _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\xg", "right"]),
_templateObject6 = /*#__PURE__*/ _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\u000g", "right"]),
_templateObject7 = /*#__PURE__*/ _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\u{-0}", "right"]);
_templateObject7 = /*#__PURE__*/ _taggedTemplateLiteral(["left", void 0, "right"], ["left", "\\u{-0}", "right"]),
_templateObject8 = /*#__PURE__*/ _taggedTemplateLiteral([void 0], ["\\01"]);
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
@@ -18,5 +19,5 @@ tag(_templateObject7, 0, 1);
function a() {
var undefined = 4;
tag(_templateObject2);
tag(_templateObject8);
}

View File

@@ -4,7 +4,8 @@ var _templateObject = /*#__PURE__*/ _taggedTemplateLiteralLoose([void 0], ["\\un
_templateObject4 = /*#__PURE__*/ _taggedTemplateLiteralLoose(["left", void 0], ["left", "\\xg"]),
_templateObject5 = /*#__PURE__*/ _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\xg", "right"]),
_templateObject6 = /*#__PURE__*/ _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\u000g", "right"]),
_templateObject7 = /*#__PURE__*/ _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\u{-0}", "right"]);
_templateObject7 = /*#__PURE__*/ _taggedTemplateLiteralLoose(["left", void 0, "right"], ["left", "\\u{-0}", "right"]),
_templateObject8 = /*#__PURE__*/ _taggedTemplateLiteralLoose([void 0], ["\\01"]);
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
@@ -18,5 +19,5 @@ tag(_templateObject7, 0, 1);
function a() {
var undefined = 4;
tag(_templateObject2);
tag(_templateObject8);
}