1 | /*! @license is-dom-node-list v1.0.2
|
2 |
|
3 | Copyright 2018 Fisssion LLC.
|
4 |
|
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 | of this software and associated documentation files (the "Software"), to deal
|
7 | in the Software without restriction, including without limitation the rights
|
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 | copies of the Software, and to permit persons to whom the Software is
|
10 | furnished to do so, subject to the following conditions:
|
11 |
|
12 | The above copyright notice and this permission notice shall be included in all
|
13 | copies or substantial portions of the Software.
|
14 |
|
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 | SOFTWARE.
|
22 |
|
23 | */
|
24 | /*! @license is-dom-node v1.0.2
|
25 |
|
26 | Copyright 2018 Fisssion LLC.
|
27 |
|
28 | Permission is hereby granted, free of charge, to any person obtaining a copy
|
29 | of this software and associated documentation files (the "Software"), to deal
|
30 | in the Software without restriction, including without limitation the rights
|
31 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
32 | copies of the Software, and to permit persons to whom the Software is
|
33 | furnished to do so, subject to the following conditions:
|
34 |
|
35 | The above copyright notice and this permission notice shall be included in all
|
36 | copies or substantial portions of the Software.
|
37 |
|
38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
39 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
40 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
41 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
42 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
43 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
44 | SOFTWARE.
|
45 |
|
46 | */
|
47 | function isDomNode(x) {
|
48 | return typeof window.Node === 'object'
|
49 | ? x instanceof window.Node
|
50 | : x !== null &&
|
51 | typeof x === 'object' &&
|
52 | typeof x.nodeType === 'number' &&
|
53 | typeof x.nodeName === 'string'
|
54 | }
|
55 |
|
56 | function isDomNodeList(x) {
|
57 | var prototypeToString = Object.prototype.toString.call(x);
|
58 | var regex = /^\[object (HTMLCollection|NodeList|Object)\]$/;
|
59 |
|
60 | return typeof window.NodeList === 'object'
|
61 | ? x instanceof window.NodeList
|
62 | : x !== null &&
|
63 | typeof x === 'object' &&
|
64 | typeof x.length === 'number' &&
|
65 | regex.test(prototypeToString) &&
|
66 | (x.length === 0 || isDomNode(x[0]))
|
67 | }
|
68 |
|
69 | export default isDomNodeList;
|