diff --git a/src/highlight.js b/src/highlight.js index bac0a5fbee..0dc394a1ca 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -108,7 +108,7 @@ https://highlightjs.org/ } } - function inherit(parent) { // inherit(parent, override_obj, override_obj, ...) + var inherit = function(parent) { // inherit(parent, override_obj, override_obj, ...) var key; var result = {}; var objects = Array.prototype.slice.call(arguments, 1); @@ -122,6 +122,15 @@ https://highlightjs.org/ return result; } + // ES2015 version (we would hope it's faster?) + if (Object.assign) { + inherit = function() { + Array.prototype.unshift.call(arguments, {}) + return Object.assign.apply(null, arguments) + } + } + + /* Stream merging */ function nodeStream(node) { @@ -415,18 +424,32 @@ https://highlightjs.org/ var match = matcherRe.exec(s); if (!match) { return null; } - for(var i = 0; i