Skip to content
Snippets Groups Projects
Commit 8cb65ce4 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

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.
parent 32992c85
No related branches found
No related tags found
No related merge requests found
...@@ -14,24 +14,4 @@ export const combineURLs = (baseURL, addedURL) => { ...@@ -14,24 +14,4 @@ export const combineURLs = (baseURL, addedURL) => {
baseURL += '/'; baseURL += '/';
} }
return new URL(addedURL.replace(/^\/+/, ''), baseURL).href; return new URL(addedURL.replace(/^\/+/, ''), baseURL).href;
}; };
\ No newline at end of file
/**
* 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;
}
import {expect, assert} from '@esm-bundle/chai'; import {expect, assert} from '@esm-bundle/chai';
import * as utils from '../utils'; import * as utils from '../utils';
import * as styles from '../styles'; import * as styles from '../styles';
import {combineURLs, getShadowRootDocument} from '../'; import {combineURLs} from '../';
import '../jsonld.js'; import '../jsonld.js';
suite('utils', () => { suite('utils', () => {
...@@ -34,16 +34,6 @@ suite('utils', () => { ...@@ -34,16 +34,6 @@ suite('utils', () => {
assert.isTrue(res); 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', () => { test('getAssetURL', () => {
// Backwards compat // Backwards compat
assert.equal(new URL(utils.getAssetURL('foo/bar')).pathname, '/foo/bar'); assert.equal(new URL(utils.getAssetURL('foo/bar')).pathname, '/foo/bar');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment