(HostElementPrototype: HTMLElement)
| 207 | * @param HostElementPrototype the `Element` to be patched |
| 208 | */ |
| 209 | export const patchSlotInsertAdjacentHTML = (HostElementPrototype: HTMLElement) => { |
| 210 | if ((HostElementPrototype as any).__insertAdjacentHTML) return; |
| 211 | const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML; |
| 212 | |
| 213 | HostElementPrototype.insertAdjacentHTML = function (this: d.HostElement, position: InsertPosition, text: string) { |
| 214 | if (position !== 'afterbegin' && position !== 'beforeend') { |
| 215 | return originalInsertAdjacentHtml.call(this, position, text); |
| 216 | } |
| 217 | const container = this.ownerDocument.createElement('_'); |
| 218 | let node: d.RenderNode; |
| 219 | container.innerHTML = text; |
| 220 | |
| 221 | if (position === 'afterbegin') { |
| 222 | while ((node = container.firstChild as d.RenderNode)) { |
| 223 | this.prepend(node); |
| 224 | } |
| 225 | } else if (position === 'beforeend') { |
| 226 | while ((node = container.firstChild as d.RenderNode)) { |
| 227 | this.append(node); |
| 228 | } |
| 229 | } |
| 230 | }; |
| 231 | }; |
| 232 | |
| 233 | /** |
| 234 | * Patches the `insertAdjacentText` method for a slotted node inside a scoped component. Specifically, |
no test coverage detected