@domql/utils 2.3.93 → 2.3.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/node.js CHANGED
@@ -18,18 +18,15 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var node_exports = {};
20
20
  __export(node_exports, {
21
- cleanWithNode: () => cleanWithNode,
22
- createID: () => createID,
23
- createSnapshotId: () => createSnapshotId
21
+ isHtmlElement: () => isHtmlElement,
22
+ isNode: () => isNode
24
23
  });
25
24
  module.exports = __toCommonJS(node_exports);
26
- const cleanWithNode = (extend) => delete extend.node && extend;
27
- const createID = function() {
28
- let index = 0;
29
- function newId() {
30
- index++;
31
- return index;
32
- }
33
- return newId;
34
- }();
35
- const createSnapshotId = createID;
25
+ var import_globals = require("@domql/globals");
26
+ const isNode = (node) => {
27
+ const { Node } = import_globals.window;
28
+ return typeof Node === "function" ? node instanceof Node : node && typeof node === "object" && typeof node.nodeType === "number" && typeof node.tag === "string";
29
+ };
30
+ const isHtmlElement = (obj) => {
31
+ return typeof import_globals.window.HTMLElement === "object" ? obj instanceof import_globals.window.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string";
32
+ };
package/dist/cjs/types.js CHANGED
@@ -24,8 +24,6 @@ __export(types_exports, {
24
24
  isBoolean: () => isBoolean,
25
25
  isDefined: () => isDefined,
26
26
  isFunction: () => isFunction,
27
- isHtmlElement: () => isHtmlElement,
28
- isNode: () => isNode,
29
27
  isNot: () => isNot,
30
28
  isNull: () => isNull,
31
29
  isNumber: () => isNumber,
@@ -36,9 +34,9 @@ __export(types_exports, {
36
34
  isValidHtmlTag: () => isValidHtmlTag
37
35
  });
38
36
  module.exports = __toCommonJS(types_exports);
39
- var import_globals = require("@domql/globals");
40
37
  var import_tags = require("@domql/tags");
41
- const isValidHtmlTag = (arg) => import_tags.HTML_TAGS.body.indexOf(arg);
38
+ var import_node = require("./node");
39
+ const isValidHtmlTag = (arg) => import_tags.HTML_TAGS.body.includes(arg);
42
40
  const isObject = (arg) => {
43
41
  if (arg === null)
44
42
  return false;
@@ -55,12 +53,6 @@ const isObjectLike = (arg) => {
55
53
  return false;
56
54
  return typeof arg === "object";
57
55
  };
58
- const isNode = (obj) => {
59
- return typeof import_globals.window.Node === "object" ? obj instanceof import_globals.window.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string";
60
- };
61
- const isHtmlElement = (obj) => {
62
- return typeof import_globals.window.HTMLElement === "object" ? obj instanceof import_globals.window.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string";
63
- };
64
56
  const isDefined = (arg) => {
65
57
  return isObject(arg) || isObjectLike(arg) || isString(arg) || isNumber(arg) || isFunction(arg) || isArray(arg) || isObjectLike(arg) || isBoolean(arg) || isNull(arg);
66
58
  };
@@ -76,8 +68,8 @@ const TYPES = {
76
68
  null: isNull,
77
69
  function: isFunction,
78
70
  objectLike: isObjectLike,
79
- node: isNode,
80
- htmlElement: isHtmlElement,
71
+ node: import_node.isNode,
72
+ htmlElement: import_node.isHtmlElement,
81
73
  defined: isDefined
82
74
  };
83
75
  const is = (arg) => {
package/node.js CHANGED
@@ -1,16 +1,23 @@
1
1
  'use strict'
2
2
 
3
- export const cleanWithNode = extend => delete extend.node && extend
3
+ import { window } from '@domql/globals'
4
4
 
5
- export const createID = (function () {
6
- let index = 0
5
+ export const isNode = (node) => {
6
+ const { Node } = window
7
+ return (
8
+ typeof Node === 'function'
9
+ ? node instanceof Node
10
+ : node &&
11
+ typeof node === 'object' &&
12
+ typeof node.nodeType === 'number' &&
13
+ typeof node.tag === 'string'
14
+ )
15
+ }
7
16
 
8
- function newId () {
9
- index++
10
- return index
11
- }
12
-
13
- return newId
14
- })()
15
-
16
- export const createSnapshotId = createID
17
+ export const isHtmlElement = obj => {
18
+ return (
19
+ typeof window.HTMLElement === 'object'
20
+ ? obj instanceof window.HTMLElement // DOM2
21
+ : obj && typeof obj === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string'
22
+ )
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.3.93",
3
+ "version": "2.3.101",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -22,5 +22,5 @@
22
22
  "@domql/globals": "latest",
23
23
  "@domql/tags": "latest"
24
24
  },
25
- "gitHead": "05d8f5ec85ad1c9cb0dc24a1fe49bd38a3d86769"
25
+ "gitHead": "d90273abc53b88938f10d1d44f211c6e35ac1c9c"
26
26
  }
package/types.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict'
2
2
 
3
- import { window } from '@domql/globals'
4
3
  import { HTML_TAGS } from '@domql/tags'
4
+ import { isHtmlElement, isNode } from './node'
5
5
 
6
- export const isValidHtmlTag = arg => HTML_TAGS.body.indexOf(arg)
6
+ export const isValidHtmlTag = arg => HTML_TAGS.body.includes(arg)
7
7
 
8
8
  export const isObject = arg => {
9
9
  if (arg === null) return false
@@ -28,22 +28,6 @@ export const isObjectLike = arg => {
28
28
  return (typeof arg === 'object')
29
29
  }
30
30
 
31
- export const isNode = obj => {
32
- return (
33
- typeof window.Node === 'object'
34
- ? obj instanceof window.Node
35
- : obj && typeof obj === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string'
36
- )
37
- }
38
-
39
- export const isHtmlElement = obj => {
40
- return (
41
- typeof window.HTMLElement === 'object'
42
- ? obj instanceof window.HTMLElement // DOM2
43
- : obj && typeof obj === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string'
44
- )
45
- }
46
-
47
31
  export const isDefined = arg => {
48
32
  return isObject(arg) ||
49
33
  isObjectLike(arg) ||