@remote-dom/polyfill 1.2.0 → 1.3.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.
@@ -1,4 +1,4 @@
1
- import {HOOKS, LISTENERS, OWNER_DOCUMENT} from './constants.ts';
1
+ import {HOOKS, PATH, LISTENERS, OWNER_DOCUMENT} from './constants.ts';
2
2
  import {fireEvent, EventPhase} from './Event.ts';
3
3
  import {CAPTURE_MARKER, type Event} from './Event.ts';
4
4
  import type {ChildNode} from './ChildNode.ts';
@@ -105,22 +105,21 @@ export class EventTarget {
105
105
  // }
106
106
  event.target = this;
107
107
  event.srcElement = this;
108
- event.path = path;
109
- let defaultPrevented = false;
110
- for (let i = path.length; --i; ) {
111
- if (fireEvent(event, path[i]!, EventPhase.CAPTURING_PHASE)) {
112
- defaultPrevented = true;
113
- }
114
- }
115
- if (fireEvent(event, this, EventPhase.AT_TARGET)) {
116
- defaultPrevented = true;
108
+ event[PATH] = path;
109
+
110
+ for (let i = path.length; i--; ) {
111
+ fireEvent(event, path[i]!, EventPhase.CAPTURING_PHASE);
112
+ if (event.cancelBubble) return event.defaultPrevented;
117
113
  }
118
- for (let i = 1; i < path.length; i++) {
119
- if (fireEvent(event, path[i]!, EventPhase.BUBBLING_PHASE)) {
120
- defaultPrevented = true;
121
- }
114
+
115
+ const bubblePath = event.bubbles ? path : path.slice(0, 1);
116
+
117
+ for (let i = 0; i < bubblePath.length; i++) {
118
+ fireEvent(event, bubblePath[i]!, EventPhase.BUBBLING_PHASE);
119
+ if (event.cancelBubble) return event.defaultPrevented;
122
120
  }
123
- return !defaultPrevented;
121
+
122
+ return event.defaultPrevented;
124
123
  }
125
124
  }
126
125
 
@@ -125,6 +125,7 @@ export class NamedNodeMap {
125
125
  attr[NS],
126
126
  );
127
127
  }
128
+
128
129
  return old;
129
130
  }
130
131
 
@@ -150,7 +151,7 @@ function updateElementAttribute(
150
151
  const {observedAttributes} = element.constructor as typeof Element;
151
152
  const {attributeChangedCallback} = element;
152
153
 
153
- if (name === 'slot' && element.slot !== newValue) {
154
+ if (name === 'slot') {
154
155
  element.slot = newValue ?? '';
155
156
  }
156
157
 
@@ -66,6 +66,7 @@ export class ParentNode extends ChildNode {
66
66
  children.splice(children.indexOf(child), 1);
67
67
  }
68
68
 
69
+ (child as any).disconnectedCallback?.();
69
70
  this[HOOKS].removeChild?.(this as any, child as any, childNodesIndex);
70
71
  }
71
72
 
@@ -153,6 +154,7 @@ export class ParentNode extends ChildNode {
153
154
  if (isElement) this.children.push(child);
154
155
  }
155
156
 
157
+ (child as any).connectedCallback?.();
156
158
  this[HOOKS].insertChild?.(this as any, child as any, insertIndex);
157
159
  }
158
160
  }
@@ -12,8 +12,9 @@ export const DATA = Symbol('data');
12
12
  export const USER_PROPERTIES = Symbol('user_properties');
13
13
  export const LISTENERS = Symbol('listeners');
14
14
  export const IS_TRUSTED = Symbol('isTrusted');
15
+ export const PATH = Symbol('path');
16
+ export const STOP_IMMEDIATE_PROPAGATION = Symbol('stop_immediate_propagation');
15
17
  export const CONTENT = Symbol('content');
16
- export const SLOT = Symbol('slot');
17
18
  export const HOOKS = Symbol('hooks');
18
19
 
19
20
  // @TODO remove explicit values