From 8cb65ce41bb59683adc6a53c15a8c8b182133d6f Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Wed, 13 Apr 2022 16:05:38 +0200 Subject: [PATCH] Remove getShadowRootDocument() again This was used to create HTML elements for a shadow dom, but this is now provided by the scoped-elements mixin via this.createScopedElement(). One way to handle this is enough, so remove this again. All users have been ported already. --- packages/common/src/utils.js | 22 +--------------------- packages/common/test/unit.js | 12 +----------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/packages/common/src/utils.js b/packages/common/src/utils.js index 7d4b7b9b..6dff2a91 100644 --- a/packages/common/src/utils.js +++ b/packages/common/src/utils.js @@ -14,24 +14,4 @@ export const combineURLs = (baseURL, addedURL) => { baseURL += '/'; } return new URL(addedURL.replace(/^\/+/, ''), baseURL).href; -}; - -/** - * Returns a Document like thing that can be used to create elements. - * - * It provides createElement()/createElementNS()/importNode(). - * The Document type annotation, while not correct, is used here for simplicity. - * - * https://github.com/WICG/webcomponents/blob/gh-pages/proposals/Scoped-Custom-Element-Registries.md#scoped-element-creation-apis - * - * @param {HTMLElement} element - * @returns {Document|null} - */ -export function getShadowRootDocument(element) { - // In case the polyfill is loaded return the shadowRoot - // otherwise fall back to the global document - if (ShadowRoot.prototype.createElement !== undefined) { - return element.shadowRoot; - } - return document; -} +}; \ No newline at end of file diff --git a/packages/common/test/unit.js b/packages/common/test/unit.js index 64c44c27..7bf4ac4d 100644 --- a/packages/common/test/unit.js +++ b/packages/common/test/unit.js @@ -1,7 +1,7 @@ import {expect, assert} from '@esm-bundle/chai'; import * as utils from '../utils'; import * as styles from '../styles'; -import {combineURLs, getShadowRootDocument} from '../'; +import {combineURLs} from '../'; import '../jsonld.js'; suite('utils', () => { @@ -34,16 +34,6 @@ suite('utils', () => { assert.isTrue(res); }); - test('getShadowRootDocument', () => { - class SomeElement3 extends HTMLElement {} - let res = utils.defineCustomElement('test-some-element-3', SomeElement3); - assert.isTrue(res); - let elm = new SomeElement3(); - elm.attachShadow({mode: 'open'}); - let doc = getShadowRootDocument(elm); - assert.isFunction(doc.createElement); - }); - test('getAssetURL', () => { // Backwards compat assert.equal(new URL(utils.getAssetURL('foo/bar')).pathname, '/foo/bar'); -- GitLab