From 98ff88ffffeaa5fe9d486f538df34293b0018720 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 27 Dec 2024 14:08:56 +0900 Subject: [PATCH] Update browser.js --- lib/browser.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/browser.js b/lib/browser.js index d009096..99646d0 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -108,6 +108,36 @@ if (!window.addEventListener) { })(window, document, global.Element.prototype, []); } +// https://stackoverflow.com/questions/45552695/why-element-matches-polyfill-doesnt-work +// https://github.com/zloirock/core-js/issues/780 +// https://github.com/joncasey/modern-hta/blob/master/src/element-closest.js +if (Element && Element.prototype) { + if (!Element.prototype.matches) { + Element.prototype.matches = Element.prototype.msMatchesSelector; + } + + if (!Element.prototype.closest) { + Element.prototype.closest = function(selector) { + for (var p = this; p != null; p = p.parentElement) { + if (p.matches(selector)) return p; + } + }; + } +} + +// https://github.com/summernote/summernote/pull/4625 +if (CanvasPixelArray && CanvasPixelArray.prototype) { + if (!CanvasPixelArray.prototype.join) { + CanvasPixelArray.prototype.join = function() { + var pxInfo = this, s = ''; + for (var i = 0; i < pxInfo.length; i++) { + s += pxInfo[i].toString(); + } + return s; + }; + } +} + // getIEVersion() function getIEVersion() { var undef, @@ -254,7 +284,7 @@ exports.start = start; exports.reload = reload; exports.close = close; -exports.VERSIONINFO = "Browser Compatibility Library (browser.js) version 0.1.6"; +exports.VERSIONINFO = "Browser Compatibility Layer (browser.js) version 0.1.7"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require;