@domql/utils 2.0.8 → 2.2.1
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/object.js +22 -8
- package/package.json +3 -3
package/object.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { HTML_TAGS } from '@domql/tags'
|
|
4
4
|
|
|
5
|
-
export const isValidHtmlTag = arg =>
|
|
5
|
+
export const isValidHtmlTag = arg => HTML_TAGS.body.indexOf(arg)
|
|
6
6
|
|
|
7
7
|
export const isObject = arg => {
|
|
8
8
|
if (arg === null) return false
|
|
@@ -119,6 +119,7 @@ export const deepClone = (obj, excluding = ['parent', 'node', '__element', '__ro
|
|
|
119
119
|
* Overwrites object properties with another
|
|
120
120
|
*/
|
|
121
121
|
export const overwrite = (element, params, options) => {
|
|
122
|
+
const { ref } = element
|
|
122
123
|
const changes = {}
|
|
123
124
|
|
|
124
125
|
for (const e in params) {
|
|
@@ -128,22 +129,35 @@ export const overwrite = (element, params, options) => {
|
|
|
128
129
|
const paramsProp = params[e]
|
|
129
130
|
|
|
130
131
|
if (paramsProp) {
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
ref.__cache[e] = changes[e] = elementProp
|
|
133
|
+
ref[e] = paramsProp
|
|
133
134
|
}
|
|
134
|
-
|
|
135
|
-
if (options.cleanExec) delete element.__exec[e]
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
return changes
|
|
139
138
|
}
|
|
140
139
|
|
|
140
|
+
export const diff = (obj, original, cache) => {
|
|
141
|
+
const changes = cache || {}
|
|
142
|
+
for (const e in obj) {
|
|
143
|
+
if (e === 'ref') continue
|
|
144
|
+
const originalProp = original[e]
|
|
145
|
+
const objProp = obj[e]
|
|
146
|
+
if (isObjectLike(originalProp) && isObjectLike(objProp)) {
|
|
147
|
+
changes[e] = {}
|
|
148
|
+
diff(originalProp, objProp, changes[e])
|
|
149
|
+
} else if (objProp !== undefined) {
|
|
150
|
+
changes[e] = objProp
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return changes
|
|
154
|
+
}
|
|
155
|
+
|
|
141
156
|
/**
|
|
142
157
|
* Overwrites DEEPly object properties with another
|
|
143
158
|
*/
|
|
144
|
-
export const overwriteDeep = (
|
|
159
|
+
export const overwriteDeep = (params, obj) => {
|
|
145
160
|
for (const e in params) {
|
|
146
|
-
if (excluding.indexOf(e) > -1) continue
|
|
147
161
|
const objProp = obj[e]
|
|
148
162
|
const paramsProp = params[e]
|
|
149
163
|
if (isObjectLike(objProp) && isObjectLike(paramsProp)) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@domql/
|
|
7
|
+
"@domql/tags": "latest"
|
|
8
8
|
},
|
|
9
|
-
"gitHead": "
|
|
9
|
+
"gitHead": "87a27f601df3c39a91dd199fb2068bb761f6ed4e",
|
|
10
10
|
"source": "index.js"
|
|
11
11
|
}
|