Skip to content

Commit

Permalink
Add support for ShadowRoot DOM api feature detect through `shadowroot…
Browse files Browse the repository at this point in the history
…` and `shadowroot-legacy` (#2475)

Co-authored-by: Kevin Coyle <kevin.coyle@theuniprogroup.com>
  • Loading branch information
2 people authored and rejas committed Oct 5, 2019
1 parent c2a9465 commit d11cd99
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
20 changes: 20 additions & 0 deletions feature-detects/dom/shadowroot.js
Original file line number Diff line number Diff line change
@@ -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'));
});
20 changes: 20 additions & 0 deletions feature-detects/dom/shadowrootlegacy.js
Original file line number Diff line number Diff line change
@@ -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'));
});
2 changes: 2 additions & 0 deletions lib/config-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
"dom/microdata",
"dom/mutationObserver",
"dom/passiveeventlisteners",
"dom/shadowroot",
"dom/shadowrootlegacy",
"elem/bdi",
"elem/datalist",
"elem/details",
Expand Down

0 comments on commit d11cd99

Please sign in to comment.