@domql/utils 0.0.1 → 0.0.2
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 +5 -2
- package/src/index.js +0 -1
- package/src/object.js +2 -2
- package/src/report.js +0 -62
package/package.json
CHANGED
package/src/index.js
CHANGED
package/src/object.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { NODE_REGISTRY } from '@domql/node'
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const isValidHtmlTag = arg => NODE_REGISTRY.body.indexOf(arg)
|
|
6
6
|
|
|
7
7
|
export const isObject = arg => {
|
|
8
8
|
if (arg === null) return false
|
package/src/report.js
DELETED
|
@@ -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
|
-
}
|