mount-observer 0.0.87 → 0.0.89

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mount-observer",
3
- "version": "0.0.87",
3
+ "version": "0.0.89",
4
4
  "description": "Observe and act on css matches.",
5
5
  "main": "MountObserver.js",
6
6
  "module": "MountObserver.js",
package/preloadContent.js CHANGED
@@ -9,7 +9,7 @@ Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
9
9
  if (window[remoteTemplElSym] === undefined) {
10
10
  window[remoteTemplElSym] = 0;
11
11
  }
12
- const id = templ.id || window[remoteTemplElSym]++;
12
+ const id = templ.id || `mount-observer-${window[remoteTemplElSym]++}`;
13
13
  const sourceTempl = document.createElement('template');
14
14
  sourceTempl.id = '' + id;
15
15
  sourceTempl.content.appendChild(templ.content);
package/preloadContent.ts CHANGED
@@ -11,7 +11,7 @@ Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
11
11
  if((<any>window)[remoteTemplElSym] === undefined ){
12
12
  (<any>window)[remoteTemplElSym] = 0;
13
13
  }
14
- const id = templ.id || (<any>window)[remoteTemplElSym]++;
14
+ const id = templ.id || `mount-observer-${(<any>window)[remoteTemplElSym]++}`;
15
15
  const sourceTempl = document.createElement('template');
16
16
  sourceTempl.id = '' + id;
17
17
  sourceTempl.content.appendChild(templ.content);
package/refid/via.js CHANGED
@@ -36,6 +36,7 @@ class RefManager extends EventTarget {
36
36
  #el;
37
37
  #children;
38
38
  #attr;
39
+ #lastAttrVal = '';
39
40
  //#parents: Array<WeakRef<Element>> | undefined;
40
41
  constructor(el, prop) {
41
42
  super();
@@ -43,15 +44,16 @@ class RefManager extends EventTarget {
43
44
  this.#el = new WeakRef(el);
44
45
  }
45
46
  get children() {
46
- if (this.#children === undefined) {
47
- const el = this.#el.deref();
48
- if (el === undefined)
49
- return [];
50
- const attr = el.getAttribute(this.#attr);
47
+ const el = this.#el.deref();
48
+ if (el === undefined)
49
+ return [];
50
+ const attr = el.getAttribute(this.#attr);
51
+ if (this.#children === undefined || attr !== this.#lastAttrVal) {
51
52
  if (!attr)
52
53
  return [];
54
+ this.#lastAttrVal = attr;
53
55
  const refIds = splitRefs(attr);
54
- const qry = refIds.map(id => `#${id}`).join(', ');
56
+ const qry = refIds.map(id => `#${id}`).join(',');
55
57
  const rn = el.getRootNode();
56
58
  const refsArr = Array.from(rn.querySelectorAll(qry));
57
59
  const refs = new Map();
package/refid/via.ts CHANGED
@@ -40,6 +40,7 @@ class RefManager extends EventTarget {
40
40
  #el: WeakRef<Element>;
41
41
  #children: Map<string, WeakRef<Element>> | undefined;
42
42
  #attr: string;
43
+ #lastAttrVal: string = '';
43
44
  //#parents: Array<WeakRef<Element>> | undefined;
44
45
  constructor(el: Element, prop: string){
45
46
  super();
@@ -47,13 +48,14 @@ class RefManager extends EventTarget {
47
48
  this.#el = new WeakRef(el);
48
49
  }
49
50
  get children(){
50
- if(this.#children === undefined){
51
- const el = this.#el.deref();
52
- if(el === undefined) return [];
53
- const attr = el.getAttribute(this.#attr);
51
+ const el = this.#el.deref();
52
+ if(el === undefined) return [];
53
+ const attr = el.getAttribute(this.#attr);
54
+ if(this.#children === undefined || attr !== this.#lastAttrVal){
54
55
  if(!attr) return [];
56
+ this.#lastAttrVal = attr;
55
57
  const refIds = splitRefs(attr);
56
- const qry = refIds.map(id => `#${id}`).join(', ');
58
+ const qry = refIds.map(id => `#${id}`).join(',');
57
59
  const rn = el.getRootNode() as DocumentFragment;
58
60
  const refsArr = Array.from(rn.querySelectorAll(qry));
59
61
  const refs = new Map<string, WeakRef<Element>>();
@@ -193,7 +193,7 @@ export interface IshConfig<TProps = any, TActions = TProps, ETProps = TProps>{
193
193
  ishListCountProp?: keyof TProps & string;
194
194
  defaultIshList?: any[];
195
195
  mapParentScopeRefTo?: keyof TProps & string;
196
- //mapElTo?: keyof TProps & string; //make sure strong use case before implementing
196
+ mapElTo?: keyof TProps & string;
197
197
  ignoreItemProp?: boolean;
198
198
  }
199
199
  export interface OConfig<TProps = any, TActions = TProps, ETProps = TProps> extends IshConfig<TProps, TActions, ETProps>{