From d11cd99ac096b5ce1978bbd0f4c3889b85088251 Mon Sep 17 00:00:00 2001 From: Pascal Lim Date: Sat, 5 Oct 2019 23:38:31 +0400 Subject: [PATCH] Add support for ShadowRoot DOM api feature detect through `shadowroot` and `shadowroot-legacy` (#2475) Co-authored-by: Kevin Coyle --- feature-detects/dom/shadowroot.js | 20 ++++++++++++++++++++ feature-detects/dom/shadowrootlegacy.js | 20 ++++++++++++++++++++ lib/config-all.json | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 feature-detects/dom/shadowroot.js create mode 100644 feature-detects/dom/shadowrootlegacy.js diff --git a/feature-detects/dom/shadowroot.js b/feature-detects/dom/shadowroot.js new file mode 100644 index 0000000000..ca2354b020 --- /dev/null +++ b/feature-detects/dom/shadowroot.js @@ -0,0 +1,20 @@ +/*! +{ + "name": "Shadow DOM API", + "property": "shadowroot", + "caniuse": "shadowdomv1", + "notes": [{ + "name": "MDN Docs", + "href": "https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot" + }], + "authors": ["Kevin Coyle (@kevin-coyle-unipro)", "Pascal Lim (@pascalim)"], + "tags": ["dom"] +} +!*/ + +/* DOC +Detects support for the Shadow DOM API. +*/ +define(['Modernizr', 'createElement'], function (Modernizr, createElement) { + Modernizr.addTest('shadowroot', 'attachShadow' in createElement('div')); +}); diff --git a/feature-detects/dom/shadowrootlegacy.js b/feature-detects/dom/shadowrootlegacy.js new file mode 100644 index 0000000000..9ad65b5773 --- /dev/null +++ b/feature-detects/dom/shadowrootlegacy.js @@ -0,0 +1,20 @@ +/*! +{ + "name": "Shadow DOM API (Legacy)", + "property": "shadowrootlegacy", + "caniuse": "shadowdom", + "notes": [{ + "name": "MDN Docs", + "href": "https://developer.mozilla.org/en-US/docs/Web/API/Element/createShadowRoot" + }], + "authors": ["Kevin Coyle (@kevin-coyle-unipro)", "Pascal Lim (@pascalim)"], + "tags": ["dom"] +} +!*/ + +/* DOC +Detects support for the Shadow DOM API. (Legacy) +*/ +define(['Modernizr', 'createElement'], function (Modernizr, createElement) { + Modernizr.addTest('shadowrootlegacy', 'createShadowRoot' in createElement('div')); +}); diff --git a/lib/config-all.json b/lib/config-all.json index 97c5e4f2ab..5b44512eb9 100644 --- a/lib/config-all.json +++ b/lib/config-all.json @@ -142,6 +142,8 @@ "dom/microdata", "dom/mutationObserver", "dom/passiveeventlisteners", + "dom/shadowroot", + "dom/shadowrootlegacy", "elem/bdi", "elem/datalist", "elem/details",