pacc 3.6.1 → 3.6.3
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/README.md +1 -1
- package/package.json +1 -1
- package/src/multiple.mjs +6 -4
package/README.md
CHANGED
|
@@ -185,7 +185,7 @@ Copies attribute values from a source object into a destination object.
|
|
|
185
185
|
* `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** target object to be modified
|
|
186
186
|
* `source` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** origin of the data to be copied
|
|
187
187
|
* `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute definitions to be used
|
|
188
|
-
* `cb` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
|
|
188
|
+
* `cb` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** callback to be executed for each copied value
|
|
189
189
|
|
|
190
190
|
## getAttributes
|
|
191
191
|
|
package/package.json
CHANGED
package/src/multiple.mjs
CHANGED
|
@@ -71,10 +71,12 @@ export function mergeAttributeDefinitions(dest, atts) {
|
|
|
71
71
|
*/
|
|
72
72
|
export function setAttributes(object, source, definitions, cb) {
|
|
73
73
|
for (const [name, def] of Object.entries(definitions)) {
|
|
74
|
-
const value = getAttribute(source, name);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
cb
|
|
74
|
+
const value = getAttribute(source, name) ?? def.default;
|
|
75
|
+
if (value !== undefined) {
|
|
76
|
+
setAttribute(object, name, value);
|
|
77
|
+
if (cb) {
|
|
78
|
+
cb(def, name, value);
|
|
79
|
+
}
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
}
|