diff --git a/app/javascript/shared/polyfills.js b/app/javascript/shared/polyfills.js index 229729779..3bc4a25a4 100644 --- a/app/javascript/shared/polyfills.js +++ b/app/javascript/shared/polyfills.js @@ -16,7 +16,27 @@ import 'yet-another-abortcontroller-polyfill'; import './polyfills/insertAdjacentElement'; import './polyfills/dataset'; -// IE 11 has no baseURI +// IE 11 has no baseURI (required by turbo) if (document.baseURI == undefined) { document.baseURI = document.URL; } + +// IE 11 has no children on DocumentFragment (required by turbo) +function polyfillChildren(proto) { + Object.defineProperty(proto, 'children', { + get: function () { + const children = []; + for (const node of this.childNodes) { + if (node.nodeType == 1) { + children.push(node); + } + } + return children; + } + }); +} + +const fragment = document.createDocumentFragment(); +if (fragment.children == undefined) { + polyfillChildren(DocumentFragment.prototype); +} diff --git a/patches/@hotwired+turbo+7.1.0.patch b/patches/@hotwired+turbo+7.1.0.patch deleted file mode 100644 index 8b41c74a0..000000000 --- a/patches/@hotwired+turbo+7.1.0.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js b/node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js -index 963422f..7820263 100644 ---- a/node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js -+++ b/node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js -@@ -551,7 +551,8 @@ class StreamMessage { - }, []); - } - get templateChildren() { -- return Array.from(this.templateElement.content.children); -+ const content = this.templateElement.content; -+ return content.children ? Array.from(content.children) : Array.from(content.childNodes).filter((tag) => tag.tagName); - } - } - StreamMessage.contentType = "text/vnd.turbo-stream.html"; -diff --git a/node_modules/@hotwired/turbo/dist/turbo.es2017-umd.js b/node_modules/@hotwired/turbo/dist/turbo.es2017-umd.js -index 101db1f..a63cfbe 100644 ---- a/node_modules/@hotwired/turbo/dist/turbo.es2017-umd.js -+++ b/node_modules/@hotwired/turbo/dist/turbo.es2017-umd.js -@@ -557,7 +557,8 @@ Copyright © 2021 Basecamp, LLC - }, []); - } - get templateChildren() { -- return Array.from(this.templateElement.content.children); -+ const content = this.templateElement.content; -+ return content.children ? Array.from(content.children) : Array.from(content.childNodes).filter((tag) => tag.tagName); - } - } - StreamMessage.contentType = "text/vnd.turbo-stream.html";