From cb9ae5a6f4873213cfaa0fc34c11576d6e592c7c Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Wed, 11 Dec 2019 16:41:02 -0500 Subject: [PATCH 1/3] FIX: IE11 issue with Object.freeze() --- src/highlight.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/highlight.js b/src/highlight.js index d8f0a069c6..db3651b8e4 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -1133,10 +1133,15 @@ https://highlightjs.org/ function deepFreeze (o) { Object.freeze(o); + var objIsFunction = typeof o === 'function'; + Object.getOwnPropertyNames(o).forEach(function (prop) { if (o.hasOwnProperty(prop) && o[prop] !== null && (typeof o[prop] === "object" || typeof o[prop] === "function") + // IE11 fix: https://github.com/highlightjs/highlight.js/issues/2318 + // TODO: remove in the future + && (objIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true) && !Object.isFrozen(o[prop])) { deepFreeze(o[prop]); } From 81759bdec1906e615677e05423d30e91958d0f63 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Thu, 12 Dec 2019 07:56:02 -0500 Subject: [PATCH 2/3] strings are immutable, no need to freeze them --- src/highlight.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/highlight.js b/src/highlight.js index db3651b8e4..d00469adda 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -1104,12 +1104,6 @@ https://highlightjs.org/ }; var constants = [ - hljs.IDENT_RE, - hljs.UNDERSCORE_IDENT_RE, - hljs.NUMBER_RE, - hljs.C_NUMBER_RE, - hljs.BINARY_NUMBER_RE, - hljs.RE_STARTERS_RE, hljs.BACKSLASH_ESCAPE, hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE, From 7965629b08cb9909a21ee8a31a10053a5cebe693 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Thu, 12 Dec 2019 09:02:28 -0500 Subject: [PATCH 3/3] changelog --- CHANGES.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 17f5dccdf9..e044ae3d71 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,13 @@ Language Improvements: - none yet. +## Version 9.17.1 + +Fixes: + +- fix(parser): resolve IE 11 issue with Object.freeze() (#2319) [Josh Goebel][] + + ## Version 9.17.0 New languages: