pacc 4.37.2 → 4.37.4

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 CHANGED
@@ -48,6 +48,7 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
48
48
  * [email\_attribute](#email_attribute)
49
49
  * [version\_attribute\_writable](#version_attribute_writable)
50
50
  * [description\_attribute](#description_attribute)
51
+ * [boolean\_attribute](#boolean_attribute)
51
52
  * [boolean\_attribute\_writable](#boolean_attribute_writable)
52
53
  * [boolean\_attribute\_writable\_true](#boolean_attribute_writable_true)
53
54
  * [boolean\_attribute\_writable\_true](#boolean_attribute_writable_true-1)
@@ -71,11 +72,11 @@ const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
71
72
  * [integer\_attribute\_writable](#integer_attribute_writable)
72
73
  * [object\_attribute](#object_attribute)
73
74
  * [url\_attribute](#url_attribute)
74
- * [url\_attribute\_writble](#url_attribute_writble)
75
+ * [url\_attribute\_writable](#url_attribute_writable)
75
76
  * [hostname\_attribute](#hostname_attribute)
76
77
  * [port\_attribute](#port_attribute)
77
78
  * [id\_attribute](#id_attribute)
78
- * [title\_attribute](#title_attribute)
79
+ * [title\_attribute\_writable](#title_attribute_writable)
79
80
  * [priority\_attribute](#priority_attribute)
80
81
  * [timeout\_attribute](#timeout_attribute)
81
82
  * [language\_attribute](#language_attribute)
@@ -174,7 +175,7 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
174
175
 
175
176
  ### Properties
176
177
 
177
- * `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
178
+ * `type` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
178
179
  * `isKey` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
179
180
  * `writable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
180
181
  * `mandatory` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
@@ -249,6 +250,10 @@ The description of the object content.
249
250
 
250
251
  Type: [AttributeDefinition](#attributedefinition)
251
252
 
253
+ ## boolean\_attribute
254
+
255
+ Type: [AttributeDefinition](#attributedefinition)
256
+
252
257
  ## boolean\_attribute\_writable
253
258
 
254
259
  Type: [AttributeDefinition](#attributedefinition)
@@ -341,7 +346,7 @@ Type: [AttributeDefinition](#attributedefinition)
341
346
 
342
347
  Type: [AttributeDefinition](#attributedefinition)
343
348
 
344
- ## url\_attribute\_writble
349
+ ## url\_attribute\_writable
345
350
 
346
351
  Type: [AttributeDefinition](#attributedefinition)
347
352
 
@@ -359,7 +364,7 @@ Unique id within.
359
364
 
360
365
  Type: [AttributeDefinition](#attributedefinition)
361
366
 
362
- ## title\_attribute
367
+ ## title\_attribute\_writable
363
368
 
364
369
  The one line description.
365
370
 
@@ -448,6 +453,7 @@ Retrive attribute values from an object.
448
453
 
449
454
  * `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** attribute value source
450
455
  * `definitions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
456
+ * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
451
457
 
452
458
  Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** values
453
459
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "4.37.2",
3
+ "version": "4.37.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -55,7 +55,7 @@ export function* attributeIterator(definition, filter, path = []) {
55
55
  if (definition) {
56
56
  for (const [name, def] of Object.entries(definition)) {
57
57
  const path2 = [...path, name];
58
- if (!filter || filter(name, def)) {
58
+ if (typeof filter !== 'function' || filter(name, def)) {
59
59
  yield [path2, def];
60
60
  }
61
61
 
@@ -2,6 +2,15 @@ import { attributeIterator } from "./attributes.mjs";
2
2
  import { getAttribute, setAttribute } from "./settergetter.mjs";
3
3
  import { prepareValue } from "./attributes.mjs";
4
4
 
5
+ function findPropertyDescriptor(obj, name) {
6
+ let descriptor;
7
+ do {
8
+ (descriptor = Object.getOwnPropertyDescriptor(obj, name)) ||
9
+ (obj = Object.getPrototypeOf(obj));
10
+ } while (!descriptor && obj);
11
+ return descriptor;
12
+ }
13
+
5
14
  export function definePropertiesFromAttributes(
6
15
  object,
7
16
  attributes,
@@ -21,19 +30,19 @@ export function definePropertiesFromAttributes(
21
30
 
22
31
  if (value !== undefined) {
23
32
  if (path.length === 1) {
24
- const op = Object.getOwnPropertyDescriptor(
25
- object.constructor.prototype,
26
- name
27
- );
28
-
29
33
  value = prepareValue(value, attribute);
30
34
 
31
35
  const property = properties[name];
32
36
 
33
- if (op?.set || property?.set) {
37
+ if (property?.set) {
34
38
  applyLater[name] = value;
35
39
  } else {
36
- properties[name] = Object.assign({ ...attribute, value }, property);
40
+ const op = findPropertyDescriptor(object, name);
41
+ if (op?.set) {
42
+ applyLater[name] = value;
43
+ } else {
44
+ properties[name] = Object.assign({ ...attribute, value }, property);
45
+ }
37
46
  }
38
47
  } else {
39
48
  setAttribute(object, name, value, attribute);