@htmlplus/element 2.4.0 → 2.5.0

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.
@@ -30,13 +30,9 @@ export function Element() {
30
30
  call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_ADOPTED);
31
31
  }
32
32
  attributeChangedCallback(attribute, prev, next) {
33
- const instance = this[CONSTANTS.API_INSTANCE];
34
- if (instance[CONSTANTS.API_LOCKED])
35
- return;
36
- const name = camelCase(attribute);
37
33
  // ensures the integrity of readonly properties to prevent potential errors.
38
34
  try {
39
- this[name] = next;
35
+ this[camelCase(attribute)] = next;
40
36
  }
41
37
  catch (_a) { }
42
38
  }
@@ -44,14 +40,13 @@ export function Element() {
44
40
  const instance = this[CONSTANTS.API_INSTANCE];
45
41
  // TODO: experimental for global config
46
42
  Object.assign(instance, getConfig('element', getTag(instance), 'property'));
43
+ instance[CONSTANTS.API_CONNECTED] = true;
47
44
  const connect = () => {
48
- instance[CONSTANTS.API_CONNECTED] = true;
49
- call(instance, CONSTANTS.LIFECYCLE_CONNECTED);
50
45
  request(instance, undefined, undefined, () => {
51
46
  call(instance, CONSTANTS.LIFECYCLE_LOADED);
52
47
  });
53
48
  };
54
- const callback = call(instance, CONSTANTS.LIFECYCLE_CONNECT);
49
+ const callback = call(instance, CONSTANTS.LIFECYCLE_CONNECTED);
55
50
  if (!(callback === null || callback === void 0 ? void 0 : callback.then))
56
51
  return connect();
57
52
  callback.then(() => connect());
@@ -22,11 +22,9 @@ export function Property(options) {
22
22
  // Defines a new getter function.
23
23
  descriptor.get = function () {
24
24
  const value = getter === null || getter === void 0 ? void 0 : getter.apply(this);
25
- // TODO: target or this
26
- target[CONSTANTS.API_LOCKED] = true;
25
+ this[CONSTANTS.API_LOCKED] = true;
27
26
  updateAttribute(this, name, value);
28
- // TODO: target or this
29
- target[CONSTANTS.API_LOCKED] = false;
27
+ this[CONSTANTS.API_LOCKED] = false;
30
28
  return value;
31
29
  };
32
30
  // TODO: Check the lifecycle
@@ -51,13 +49,13 @@ export function Property(options) {
51
49
  return;
52
50
  this[symbol] = next;
53
51
  request(this, name, previous, (skipped) => {
54
- if (!(options === null || options === void 0 ? void 0 : options.reflect) || skipped)
52
+ if (skipped)
55
53
  return;
56
- // TODO: target or this
57
- target[CONSTANTS.API_LOCKED] = true;
54
+ if (!(options === null || options === void 0 ? void 0 : options.reflect))
55
+ return;
56
+ this[CONSTANTS.API_LOCKED] = true;
58
57
  updateAttribute(this, name, next);
59
- // TODO: target or this
60
- target[CONSTANTS.API_LOCKED] = false;
58
+ this[CONSTANTS.API_LOCKED] = false;
61
59
  });
62
60
  }
63
61
  // Attaches the getter and setter functions to the current property of the target class.
@@ -73,6 +71,9 @@ export function Property(options) {
73
71
  const set = descriptor
74
72
  ? undefined
75
73
  : (input) => {
74
+ if (this[CONSTANTS.API_LOCKED]) {
75
+ return;
76
+ }
76
77
  this[key] = toProperty(input, options === null || options === void 0 ? void 0 : options.type);
77
78
  };
78
79
  // TODO: Check the configuration.
@@ -16,7 +16,6 @@ export declare const DECORATOR_STATE = "State";
16
16
  export declare const DECORATOR_METHOD = "Method";
17
17
  export declare const ELEMENT_HOST_NAME = "host";
18
18
  export declare const LIFECYCLE_ADOPTED = "adoptedCallback";
19
- export declare const LIFECYCLE_CONNECT = "connectCallback";
20
19
  export declare const LIFECYCLE_CONNECTED = "connectedCallback";
21
20
  export declare const LIFECYCLE_CONSTRUCTED = "constructedCallback";
22
21
  export declare const LIFECYCLE_DISCONNECTED = "disconnectedCallback";
@@ -22,7 +22,6 @@ export const DECORATOR_METHOD = 'Method';
22
22
  export const ELEMENT_HOST_NAME = 'host';
23
23
  // lifecycle
24
24
  export const LIFECYCLE_ADOPTED = 'adoptedCallback';
25
- export const LIFECYCLE_CONNECT = 'connectCallback';
26
25
  export const LIFECYCLE_CONNECTED = 'connectedCallback';
27
26
  export const LIFECYCLE_CONSTRUCTED = 'constructedCallback';
28
27
  export const LIFECYCLE_DISCONNECTED = 'disconnectedCallback';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlplus/element",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "author": "Masood Abdolian <m.abdolian@gmail.com>",
package/types/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- /**
2
- * @deprecated Use `HTMLPlusElement` instead.
3
- */
4
- export interface PlusElement {
5
- }
6
- export interface HTMLPlusElement extends PlusElement {
1
+ export interface HTMLPlusElement {
2
+ adoptedCallback?(): void;
3
+ connectedCallback?(): void;
4
+ constructedCallback?(): void;
5
+ disconnectedCallback?(): void;
6
+ loadedCallback?(): void;
7
+ updateCallback?(states: Map<string, any>): void;
8
+ updatedCallback?(states: Map<string, any>): void;
7
9
  }