-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,6 +239,7 @@ | |
"isRetina", | ||
"isRunning", | ||
"isSet", | ||
"isShadowRoot", | ||
"isSorted", | ||
"isStr", | ||
"isStrBlank", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## CN | ||
|
||
检查值是否是 ShadowRoot 对象。 | ||
|
||
|参数名|说明| | ||
|-----|---| | ||
|val|要检查的值| | ||
|返回值|如果是 ShadowRoot,返回真| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* Check if value is a ShadowRoot object. | ||
* | ||
* |Name |Desc | | ||
* |------|-----------------------------| | ||
* |val |Value to check | | ||
* |return|True if value is a ShadowRoot| | ||
*/ | ||
|
||
/* example | ||
* isShadowRoot(document.body); // -> false | ||
*/ | ||
|
||
/* module | ||
* env: browser | ||
*/ | ||
|
||
/* typescript | ||
* export declare function isShadowRoot(val: any): val is ShadowRoot; | ||
*/ | ||
|
||
exports = function(val) { | ||
if (window.ShadowRoot) { | ||
return val instanceof ShadowRoot; | ||
} | ||
|
||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
it('true', function() { | ||
expect( | ||
isShadowRoot( | ||
document.createElement('div').attachShadow({ mode: 'open' }) | ||
) | ||
).to.be.true; | ||
}); | ||
|
||
it('false', function() { | ||
expect(isShadowRoot(document.body)).to.be.false; | ||
expect(isShadowRoot(document.createElement('div'))).to.be.false; | ||
}); |