From bc914e6f23dfaec1dfd6c7c3b96b298b1c2084a1 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 22 Dec 2014 21:36:59 +1100 Subject: [PATCH] freeze tagged template literal object - fixes #328 --- lib/6to5/templates/tagged-template-literal.js | 2 +- .../transformation/es6-template-literals/tag/expected.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/6to5/templates/tagged-template-literal.js b/lib/6to5/templates/tagged-template-literal.js index 9d3b26a3b7..a1735f0fc7 100644 --- a/lib/6to5/templates/tagged-template-literal.js +++ b/lib/6to5/templates/tagged-template-literal.js @@ -1,4 +1,4 @@ (function (strings, raw) { - return Object.defineProperties(strings, { raw: { value: raw } }); + return Object.freeze(Object.defineProperties(strings, { raw: { value: raw } })); }); diff --git a/test/fixtures/transformation/es6-template-literals/tag/expected.js b/test/fixtures/transformation/es6-template-literals/tag/expected.js index 9992ad8f15..6d6de74206 100644 --- a/test/fixtures/transformation/es6-template-literals/tag/expected.js +++ b/test/fixtures/transformation/es6-template-literals/tag/expected.js @@ -1,11 +1,11 @@ "use strict"; var _taggedTemplateLiteral = function (strings, raw) { - return Object.defineProperties(strings, { + return Object.freeze(Object.defineProperties(strings, { raw: { value: raw } - }); + })); }; var foo = bar(_taggedTemplateLiteral(["wow\na", "b ", ""], ["wow\\na", "b ", ""]), 42, _.foobar());