domql 1.5.98 → 1.5.100

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "domql",
3
3
  "description": "DOM rendering Javascript framework at early stage.",
4
4
  "author": "symbo.ls",
5
- "version": "1.5.98",
5
+ "version": "1.5.100",
6
6
  "repository": "https://github.com/domql/domql",
7
7
  "publishConfig": {
8
8
  "registry": "https://registry.npmjs.org"
@@ -25,7 +25,9 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@domql/globals": "latest",
28
- "@domql/utils": "latest"
28
+ "@domql/utils": "latest",
29
+ "@domql/registry": "latest",
30
+ "@domql/report": "latest"
29
31
  },
30
32
  "devDependencies": {
31
33
  "@babel/core": "^7.20.12",
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  // import DOM from '../../src'
4
- import { isObjectLike, exec, isObject, isEqualDeep } from '../../src/utils'
4
+ import { isObjectLike, exec, isObject, isEqualDeep } from '@domql/utils'
5
5
  import { classList } from '../../src/element/mixins'
6
6
  import createEmotion from '@emotion/css/create-instance'
7
7
  const ENV = process.env.NODE_ENV
@@ -1,29 +1 @@
1
1
  'use strict'
2
-
3
- export const isObject = arg => {
4
- if (arg === null) return false
5
- return (typeof arg === 'object') && (arg.constructor === Object)
6
- }
7
-
8
- export const isString = arg => typeof arg === 'string'
9
-
10
- export const isNumber = arg => typeof arg === 'number'
11
-
12
- export const isFunction = arg => typeof arg === 'function'
13
-
14
- export const isArray = arg => Array.isArray(arg)
15
-
16
- export const isObjectLike = arg => {
17
- if (arg === null) return false
18
- return (typeof arg === 'object')
19
- }
20
-
21
- export const isDefined = arg => {
22
- return isObject(arg) ||
23
- isObjectLike(arg) ||
24
- isString(arg) ||
25
- isNumber(arg) ||
26
- isFunction(arg) ||
27
- isArray(arg) ||
28
- isObjectLike(arg)
29
- }
@@ -1,8 +1,11 @@
1
1
  'use strict'
2
2
 
3
3
  import { document } from '@domql/globals'
4
+ import { exec, isString } from '@domql/utils'
5
+ import { report } from '@domql/report'
6
+
4
7
  import { can } from '../event'
5
- import { exec, isString, isTagRegistered, report } from '../utils'
8
+ import { isTagRegistered } from '../utils'
6
9
 
7
10
  const cachedElements = {}
8
11
 
@@ -1,23 +1,23 @@
1
1
  'use strict'
2
2
 
3
+ import { isObject, isFunction, isString, createID, isNode, exec, is } from '@domql/utils'
4
+ import { TAGS } from '@domql/registry'
5
+
3
6
  import root from './root'
4
7
  import createNode from './node'
5
8
  import { appendNode, assignNode } from './assign'
6
9
  import { applyExtend } from './extend'
7
- import nodes from './nodes'
8
10
  import set, { removeContentElement } from './set'
9
11
  import createState from './state'
10
12
  import createProps from './props'
11
13
  import update from './update'
12
14
  import { on } from '../event'
13
15
  import { assignClass } from './mixins/classList'
14
- import { isObject, isFunction, isString, createID, isNode, exec } from '../utils'
15
16
  import { remove, lookup, setProps, log, keys, parse, parseDeep, spotByPath, nextElement, previousElement, isMethod } from './methods'
16
17
  import cacheNode, { detectTag } from './cache'
17
18
  import { registry } from './mixins'
18
19
  import { throughInitialExec } from './iterate'
19
20
  import OPTIONS from './options'
20
- import { is } from '@domql/utils'
21
21
  // import { overwrite, clone, fillTheRest } from '../utils'
22
22
 
23
23
  const ENV = process.env.NODE_ENV
@@ -30,7 +30,9 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
30
30
 
31
31
  // if ELEMENT is not given
32
32
  if (element === undefined) {
33
- if (ENV === 'test' || ENV === 'development') { console.warn(key, 'element is undefined in', parent && parent.path) }
33
+ if (ENV === 'test' || ENV === 'development') {
34
+ console.warn(key, 'element is undefined in', parent && parent.__ref && parent.__ref.path)
35
+ }
34
36
  element = {}
35
37
  }
36
38
  if (element === null) return
@@ -142,7 +144,7 @@ const checkIfPrimitive = (element) => {
142
144
  const applyValueAsText = (element, parent, key) => {
143
145
  const extendTag = element.extend && element.extend.tag
144
146
  const childExtendTag = parent.childExtend && parent.childExtend.tag
145
- const isKeyValidHTMLTag = ((nodes.body.indexOf(key) > -1) && key)
147
+ const isKeyValidHTMLTag = ((TAGS.body.indexOf(key) > -1) && key)
146
148
  return {
147
149
  text: element,
148
150
  tag: extendTag || childExtendTag || isKeyValidHTMLTag || 'string'
@@ -189,6 +191,7 @@ const checkIf = (element, parent) => {
189
191
 
190
192
  const addCaching = (element, parent) => {
191
193
  const { __ref } = element
194
+ let { __ref: __parentRef } = parent
192
195
 
193
196
  // enable TRANSFORM in data
194
197
  if (!element.transform) element.transform = {}
@@ -214,12 +217,13 @@ const addCaching = (element, parent) => {
214
217
 
215
218
  // Add _root element property
216
219
  const hasRoot = parent && parent.key === ':root'
217
- if (!element.__root) element.__root = hasRoot ? element : parent.__root
220
+ if (!__ref.__root) __ref.__root = hasRoot ? element : parent.__ref.__root
218
221
 
219
222
  // set the PATH array
220
223
  if (ENV === 'test' || ENV === 'development') {
221
- if (!parent.path) parent.path = []
222
- element.path = parent.path.concat(element.key)
224
+ if (!__parentRef) __parentRef = parent.__ref = {}
225
+ if (!__parentRef.__path) __parentRef.__path = []
226
+ __ref.__path = __parentRef.__path.concat(element.key)
223
227
  }
224
228
  }
225
229
 
@@ -255,14 +259,14 @@ const resolveExtends = (element, parent, options) => {
255
259
  delete element.__element
256
260
 
257
261
  // added by createProps
258
- delete element.__props // TODO: check with NikaOto and remove
262
+ delete element.__props // TODO: check with @Nikaoto and remove
259
263
  delete element.props.__element
260
264
  delete element.props.update
261
265
 
262
266
  // added by createState
263
267
  delete element.state.__element
264
268
  delete element.state.__element
265
- delete element.__hasRootState // TODO: check with NikaOto and remove
269
+ delete element.__hasRootState // TODO: check with @Nikaoto and remove
266
270
  delete element.__ref
267
271
 
268
272
  return element
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ import { report } from '@domql/report'
3
4
  import { registry } from './mixins'
4
- import { report } from '../utils'
5
5
 
6
6
  export default (params, options = {}) => {
7
7
  const { overwrite } = options
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import { isFunction, exec, getExtendStack, jointStacks, cloneAndMergeArrayExtend, deepMergeExtend, isString } from '../utils'
3
+ import { isFunction, exec, isString } from '@domql/utils'
4
+ import { getExtendStack, jointStacks, cloneAndMergeArrayExtend, deepMergeExtend } from '../utils'
4
5
 
5
6
  const ENV = process.env.NODE_ENV
6
7
 
@@ -1,6 +1,5 @@
1
1
  'use strict'
2
2
 
3
- import nodes from './nodes'
4
3
  import root from './root'
5
4
  import tree from './tree'
6
5
  import cache from './cache'
@@ -15,7 +14,6 @@ import set from './set'
15
14
  import { lookup, remove, get, setProps, log, keys } from './methods'
16
15
 
17
16
  export {
18
- nodes,
19
17
  root,
20
18
  tree,
21
19
  cache,
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import { isObject, exec, isFunction, isNumber, isString, overwrite } from '../utils'
3
+ import { isObject, exec, isFunction, isNumber, isString } from '@domql/utils'
4
+ import { overwrite } from '../utils'
4
5
  import { isMethod } from './methods'
5
6
 
6
7
  export const applyEvents = element => {
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { isFunction, isObjectLike } from '../utils'
3
+ import { isFunction, isObjectLike } from '@domql/utils'
4
4
  import { parseFilters, registry } from './mixins'
5
5
  import root from './root'
6
6
 
@@ -98,11 +98,12 @@ export const parseDeep = function () {
98
98
 
99
99
  export const log = function (...args) {
100
100
  const element = this
101
+ const { __ref } = element
101
102
  console.group(element.key)
102
103
  if (args.length) {
103
104
  args.forEach(v => console.log(`%c${v}:\n`, 'font-weight: bold', element[v]))
104
105
  } else {
105
- console.log(element.path)
106
+ console.log(__ref.path)
106
107
  const keys = element.keys()
107
108
  keys.forEach(v => console.log(`%c${v}:\n`, 'font-weight: bold', element[v]))
108
109
  }
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import { isNot } from '@domql/utils'
4
- import { exec, report } from '../../utils'
3
+ import { exec, isNot } from '@domql/utils'
4
+ import { report } from '@domql/report'
5
5
 
6
6
  /**
7
7
  * Recursively add attributes to a DOM node
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { exec, isObject, isString } from '../../utils'
3
+ import { exec, isObject, isString } from '@domql/utils'
4
4
 
5
5
  export const assignClass = (element) => {
6
6
  const { key } = element
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import { exec, isObject } from '../../utils'
4
- import { report } from '../../utils/report'
3
+ import { exec, isObject } from '@domql/utils'
4
+ import { report } from '@domql/report'
5
5
 
6
6
  /**
7
7
  * Apply data parameters on the DOM nodes
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { exec } from '../../utils'
3
+ import { exec } from '@domql/utils'
4
4
 
5
5
  /**
6
6
  * Appends raw HTML as content
@@ -26,7 +26,6 @@ export default {
26
26
  transform: {},
27
27
  __ref: {},
28
28
  __hash: {},
29
- __root: {},
30
29
  __text: {},
31
30
  nextElement: {},
32
31
  previousElement: {},
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { exec, isObject } from '../../utils'
3
+ import { exec, isObject } from '@domql/utils'
4
4
  import { IGNORE_STATE_PARAMS } from '../state'
5
5
 
6
6
  export default (params, element, node) => {
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import { isObject, map } from '../../utils'
4
- import { report } from '../../utils/report'
3
+ import { isObject, map } from '@domql/utils'
4
+ import { report } from '@domql/report'
5
5
 
6
6
  /**
7
7
  * Recursively add styles to a DOM node
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { create } from '..'
4
- import { exec } from '../../utils'
4
+ import { exec } from '@domql/utils'
5
5
 
6
6
  /**
7
7
  * Creates a text node and appends into
@@ -1,10 +1,10 @@
1
1
  'use strict'
2
2
 
3
+ import { exec, isFunction, isObject } from '@domql/utils'
3
4
  import create from './create'
4
5
  import cacheNode from './cache'
5
6
  import * as on from '../event/on'
6
7
 
7
- import { exec, isFunction, isObject } from '../utils'
8
8
  import {
9
9
  throughInitialDefine,
10
10
  throughInitialExec,
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import { deepClone, deepMerge, exec, isArray, isObject, isString } from '../utils'
3
+ import { exec, isArray, isObject, isString } from '@domql/utils'
4
+ import { deepClone, deepMerge } from '../utils'
4
5
 
5
6
  const createPropsStack = (element, parent) => {
6
7
  const { props, __ref } = element
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { document } from '@domql/globals'
4
- import { report } from '../utils'
4
+ import { report } from '@domql/report'
5
5
 
6
6
  const root = {
7
7
  key: ':root',
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ import { isEqualDeep, isFunction } from '@domql/utils'
3
4
  import create from './create'
4
- import { isEqualDeep, isFunction } from '../utils'
5
5
  import { registry } from './mixins'
6
6
  import OPTIONS from './options'
7
7
 
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  import { on } from '../event'
4
- import { deepClone, exec, overwriteShallow, overwriteDeep } from '../utils'
5
- import { is, isObject, isFunction, isUndefined } from '@domql/utils'
4
+ import { is, isObject, exec, isFunction, isUndefined } from '@domql/utils'
5
+ import { deepClone, overwriteShallow, overwriteDeep } from '../utils'
6
6
 
7
7
  export const IGNORE_STATE_PARAMS = [
8
8
  'update', 'parse', 'clean', 'create', 'parent', '__element', '__depends', '__ref', '__root',
@@ -35,7 +35,7 @@ export const cleanState = function () {
35
35
  export const projectSystemUpdate = function (obj, options = {}) {
36
36
  const state = this
37
37
  if (!state) return
38
- const rootState = (state.__element.__root || state.__element).state
38
+ const rootState = (state.__element.__ref.__root || state.__element).state
39
39
  rootState.update({ PROJECT_SYSTEM: obj }, options)
40
40
  return state
41
41
  }
@@ -43,7 +43,7 @@ export const projectSystemUpdate = function (obj, options = {}) {
43
43
  export const projectStateUpdate = function (obj, options = {}) {
44
44
  const state = this
45
45
  if (!state) return
46
- const rootState = (state.__element.__root || state.__element).state
46
+ const rootState = (state.__element.__ref.__root || state.__element).state
47
47
  rootState.update({ PROJECT_STATE: obj }, options)
48
48
  return state
49
49
  }
@@ -100,7 +100,7 @@ export const updateState = function (obj, options = {}) {
100
100
  export const createState = function (element, parent, opts) {
101
101
  const skip = (opts && opts.skip) ? opts.skip : false
102
102
 
103
- let { state, __root, __ref: __elementRef } = element
103
+ let { state, __ref: __elementRef } = element
104
104
 
105
105
  if (isFunction(state)) state = exec(state, element)
106
106
 
@@ -179,7 +179,7 @@ export const createState = function (element, parent, opts) {
179
179
  state.create = createState
180
180
  state.parent = element.parent.state
181
181
  state.__element = element
182
- state.__root = __root ? __root.state : state
182
+ state.__root = __elementRef.__root ? __elementRef.__root.state : state
183
183
 
184
184
  // editor stuff
185
185
  state.projectSystemUpdate = projectSystemUpdate
@@ -1,9 +1,10 @@
1
1
  'use strict'
2
2
 
3
3
  import { window } from '@domql/globals'
4
- import { diff } from '@domql/utils'
4
+ import { diff, isFunction, isNumber, isObject, isString } from '@domql/utils'
5
+ import { createSnapshotId, merge, overwrite } from '../utils'
6
+
5
7
  import { on } from '../event'
6
- import { createSnapshotId, isFunction, isNumber, isObject, isString, merge, overwrite } from '../utils'
7
8
  import create from './create'
8
9
  import { throughUpdatedDefine, throughUpdatedExec } from './iterate'
9
10
  import { isMethod } from './methods'
@@ -53,7 +54,8 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
53
54
  if (ifPassed) __ref.__if = true
54
55
  if (itWasFalse && ifPassed) {
55
56
  delete element.__hash
56
- if (!__ref.__hasRootState || __ref.__state) delete element.state
57
+ if (!__ref.__hasRootState) delete element.state
58
+ if (__ref.__state) element.state = __ref.__state
57
59
  const created = create(element, element.parent, element.key)
58
60
  if (!options.preventUpdate && element.on && isFunction(element.on.update)) {
59
61
  on.update(element.on.update, created, created.state)
package/src/event/can.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict'
2
2
 
3
- import { nodes } from '../element'
4
- import { report } from '../utils'
3
+ import { TAGS } from '@domql/registry'
4
+ import { report } from '@domql/report'
5
5
 
6
6
  export const render = (element) => {
7
7
  const tag = element.tag || 'div'
8
- const isValid = nodes.body.indexOf(tag) > -1
8
+ const isValid = TAGS.body.indexOf(tag) > -1
9
9
  return isValid || report('HTMLInvalidTag')
10
10
  }
@@ -50,7 +50,7 @@ export const flattenExtend = (extend, stack) => {
50
50
  export const deepCloneExtend = obj => {
51
51
  const o = {}
52
52
  for (const prop in obj) {
53
- if (['parent', 'node', '__element', '__root', '__key'].indexOf(prop) > -1) continue
53
+ if (['parent', 'node', '__element'].indexOf(prop) > -1) continue
54
54
  const objProp = obj[prop]
55
55
  if (isObject(objProp)) {
56
56
  o[prop] = deepCloneExtend(objProp)
@@ -63,7 +63,7 @@ export const deepCloneExtend = obj => {
63
63
 
64
64
  export const deepMergeExtend = (element, extend) => {
65
65
  for (const e in extend) {
66
- if (['parent', 'node', '__element', '__root', '__key'].indexOf(e) > -1) continue
66
+ if (['parent', 'node', '__element'].indexOf(e) > -1) continue
67
67
  const elementProp = element[e]
68
68
  const extendProp = extend[e]
69
69
  if (elementProp === undefined) {
@@ -1,6 +1,4 @@
1
1
  'use strict'
2
2
 
3
- export * from './report'
4
3
  export * from './object'
5
- export * from './node'
6
4
  export * from './extendUtils'
@@ -1,87 +1,9 @@
1
1
  'use strict'
2
2
 
3
- import { window } from '@domql/globals'
4
- import nodes from '../element/nodes'
5
-
6
- export const memoize = (fn) => {
7
- const cache = {}
8
- return (...args) => {
9
- const n = args[0]
10
- if (n in cache) {
11
- return cache[n]
12
- } else {
13
- const result = fn(n)
14
- cache[n] = result
15
- return result
16
- }
17
- }
18
- }
19
-
20
- export const debounce = (element, func, timeout = 300) => {
21
- let timer
22
- return (...args) => {
23
- clearTimeout(timer)
24
- timer = setTimeout(() => { func.apply(element, args) }, timeout)
25
- }
26
- }
27
-
28
- export const isTagRegistered = arg => nodes.body.indexOf(arg)
29
-
30
- export const isObject = arg => {
31
- if (arg === null) return false
32
- return (typeof arg === 'object') && (arg.constructor === Object)
33
- }
34
-
35
- export const isString = arg => typeof arg === 'string'
36
-
37
- export const isNumber = arg => typeof arg === 'number'
38
-
39
- export const isFunction = arg => typeof arg === 'function'
40
-
41
- export const isArray = arg => Array.isArray(arg)
42
-
43
- export const isObjectLike = arg => {
44
- if (arg === null) return false
45
- // if (isArray(arg)) return false
46
- return (typeof arg === 'object')
47
- }
48
-
49
- export const isNode = obj => {
50
- return (
51
- typeof window.Node === 'object'
52
- ? obj instanceof window.Node
53
- : obj && typeof obj === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string'
54
- )
55
- }
56
-
57
- export const isHtmlElement = obj => {
58
- return (
59
- typeof window.HTMLElement === 'object'
60
- ? obj instanceof window.HTMLElement // DOM2
61
- : obj && typeof obj === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string'
62
- )
63
- }
64
-
65
- export const isDefined = arg => {
66
- return isObject(arg) ||
67
- isObjectLike(arg) ||
68
- isString(arg) ||
69
- isNumber(arg) ||
70
- isFunction(arg) ||
71
- isArray(arg) ||
72
- isObjectLike(arg)
73
- }
74
-
75
- export const exec = (param, element, state) => {
76
- if (isFunction(param)) return param(element, state || element.state)
77
- return param
78
- }
3
+ import { TAGS } from '@domql/registry'
4
+ import { isArray, isObject, isObjectLike } from '@domql/utils'
79
5
 
80
- export const map = (obj, extention, element) => {
81
- for (const e in extention) {
82
- obj[e] = exec(extention[e], element)
83
- }
84
- }
6
+ export const isTagRegistered = arg => TAGS.body.indexOf(arg)
85
7
 
86
8
  export const merge = (element, obj) => {
87
9
  for (const e in obj) {
@@ -121,7 +43,7 @@ export const clone = obj => {
121
43
  /**
122
44
  * Deep cloning of object
123
45
  */
124
- export const deepClone = (obj, excluding = ['parent', 'node', '__element', 'state', '__root', '__cached', 'context', 'extend', '__ref']) => {
46
+ export const deepClone = (obj, excluding = ['parent', 'node', '__element', 'state', 'context', 'extend', '__ref']) => {
125
47
  const o = isArray(obj) ? [] : {}
126
48
  for (const prop in obj) {
127
49
  if (excluding.indexOf(prop) > -1) continue
@@ -136,26 +58,6 @@ export const deepClone = (obj, excluding = ['parent', 'node', '__element', 'stat
136
58
  return o
137
59
  }
138
60
 
139
- /**
140
- * Overwrites object properties with another
141
- */
142
- export const isEqualDeep = (param, element) => {
143
- if (param === element) return true
144
- if (!param || !element) return false
145
- for (const prop in param) {
146
- const paramProp = param[prop]
147
- const elementProp = element[prop]
148
- if (isObjectLike(paramProp)) {
149
- const isEqual = isEqualDeep(paramProp, elementProp)
150
- if (!isEqual) return false
151
- } else {
152
- const isEqual = paramProp === elementProp
153
- if (!isEqual) return false
154
- }
155
- }
156
- return true
157
- }
158
-
159
61
  /**
160
62
  * Overwrites object properties with another
161
63
  */
@@ -181,7 +83,7 @@ export const overwrite = (element, params, options) => {
181
83
  return changes
182
84
  }
183
85
 
184
- export const overwriteShallow = (obj, params, excluding = ['node', '__root', '__ref']) => {
86
+ export const overwriteShallow = (obj, params, excluding = ['node', '__ref']) => {
185
87
  for (const e in params) {
186
88
  if (excluding.indexOf(e) > -1) continue
187
89
  obj[e] = params[e]
@@ -192,7 +94,7 @@ export const overwriteShallow = (obj, params, excluding = ['node', '__root', '__
192
94
  /**
193
95
  * Overwrites DEEPly object properties with another
194
96
  */
195
- export const overwriteDeep = (obj, params, excluding = ['node', '__root', '__ref']) => {
97
+ export const overwriteDeep = (obj, params, excluding = ['node', '__ref']) => {
196
98
  for (const e in params) {
197
99
  if (excluding.indexOf(e) > -1) continue
198
100
  const objProp = obj[e]
@@ -217,7 +119,7 @@ export const mergeIfExisted = (a, b) => {
217
119
  /**
218
120
  * Merges array extends
219
121
  */
220
- export const mergeArray = (arr, excluding = ['parent', 'node', '__element', 'state', '__root', '__cached', 'context', '__ref']) => {
122
+ export const mergeArray = (arr, excluding = ['parent', 'node', '__element', 'state', 'context', '__ref']) => {
221
123
  return arr.reduce((a, c) => deepMerge(a, deepClone(c, excluding)), {})
222
124
  }
223
125
 
package/src/utils/node.js DELETED
@@ -1,14 +0,0 @@
1
- 'use strict'
2
-
3
- export const createID = (function () {
4
- let index = 0
5
-
6
- function newId () {
7
- index++
8
- return index
9
- }
10
-
11
- return newId
12
- })()
13
-
14
- export const createSnapshotId = createID
@@ -1,62 +0,0 @@
1
- 'use strict'
2
-
3
- export const errors = {
4
- en: {
5
- DocumentNotDefined: {
6
- title: 'Document is undefined',
7
- description: 'To tweak with DOM, you should use browser.'
8
- },
9
- OverwriteToBuiltin: {
10
- title: 'Overwriting to builtin method',
11
- description: 'Overwriting a builtin method in the global define is not possible, please choose different name'
12
- },
13
- BrowserNotDefined: {
14
- title: 'Can\'t recognize environment',
15
- description: 'Environment should be browser application, that can run Javascript'
16
- },
17
- SetQuickPreferancesIsNotObject: {
18
- title: 'Quick preferances object is required',
19
- description: 'Please pass a plain object with "lang", "culture" and "area" properties'
20
- },
21
- InvalidParams: {
22
- title: 'Params are invalid',
23
- description: 'Please pass a plain object with "lang", "culture" and "area" properties'
24
- },
25
- CantCreateWithoutNode: {
26
- title: 'You must provide node',
27
- description: 'Can\'t create DOM element without setting node or text'
28
- },
29
- HTMLInvalidTag: {
30
- title: 'Element tag name (or DOM nodeName) is invalid',
31
- description: 'To create element, you must provide valid DOM node. See full list of them at here: http://www.w3schools.com/tags/'
32
- },
33
- HTMLInvalidAttr: {
34
- title: 'Attibutes object is invalid',
35
- description: 'Please pass a valid plain object to apply as an attributes for a DOM node'
36
- },
37
- HTMLInvalidData: {
38
- title: 'Data object is invalid',
39
- description: 'Please pass a valid plain object to apply as an dataset for a DOM node'
40
- },
41
- HTMLInvalidStyles: {
42
- title: 'Styles object is invalid',
43
- description: 'Please pass a valid plain object to apply as an style for a DOM node'
44
- },
45
- HTMLInvalidText: {
46
- title: 'Text string is invalid',
47
- description: 'Please pass a valid string to apply text to DOM node'
48
- }
49
- }
50
- }
51
-
52
- export const report = (err, arg, element) => {
53
- const currentLang = 'en'
54
- let errObj
55
- if (err && typeof err === 'string') errObj = errors[currentLang][err]
56
-
57
- return new Error(
58
- `"${err}", "${arg}"\n\n`,
59
- `${errObj.description}`,
60
- element ? `\n\n${element}` : ''
61
- )
62
- }