mount-observer 0.0.83 → 0.0.85

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.83",
3
+ "version": "0.0.85",
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 = window[remoteTemplElSym]++;
12
+ const id = templ.id || window[remoteTemplElSym]++;
13
13
  const sourceTempl = document.createElement('template');
14
14
  sourceTempl.id = '' + id;
15
15
  sourceTempl.content.appendChild(templ.content);
@@ -23,7 +23,7 @@ Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
23
23
  {
24
24
  const test = templ[remoteTemplElSym]?.deref();
25
25
  if (test !== undefined)
26
- return test;
26
+ return test.content;
27
27
  if (templ.getAttribute('rel') !== 'preload')
28
28
  throw 'NI';
29
29
  const isIntraDoc = src[0] === '#';
@@ -34,6 +34,7 @@ Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
34
34
  if (!(remoteTempl instanceof HTMLTemplateElement))
35
35
  throw 404; //not found
36
36
  templ[remoteTemplElSym] = new WeakRef(remoteTempl);
37
+ return remoteTempl.content;
37
38
  //templ.dispatchEvent(new Event('load'));
38
39
  }
39
40
  }
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 = (<any>window)[remoteTemplElSym]++;
14
+ const id = templ.id || (<any>window)[remoteTemplElSym]++;
15
15
  const sourceTempl = document.createElement('template');
16
16
  sourceTempl.id = '' + id;
17
17
  sourceTempl.content.appendChild(templ.content);
@@ -24,7 +24,7 @@ Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
24
24
  }
25
25
  {
26
26
  const test = (<any>templ)[remoteTemplElSym]?.deref();
27
- if(test !== undefined) return test;
27
+ if(test !== undefined) return test.content;
28
28
  if(templ.getAttribute('rel') !== 'preload') throw 'NI';
29
29
  const isIntraDoc = src[0] === '#';
30
30
  if(!isIntraDoc) throw 'NI';
@@ -32,6 +32,7 @@ Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
32
32
  const remoteTempl = upShadowSearch(templ, id);
33
33
  if(!(remoteTempl instanceof HTMLTemplateElement)) throw 404; //not found
34
34
  (<any>templ)[remoteTemplElSym] = new WeakRef(remoteTempl);
35
+ return remoteTempl.content;
35
36
  //templ.dispatchEvent(new Event('load'));
36
37
  }
37
38
 
package/upShadowSearch.js CHANGED
@@ -13,6 +13,10 @@ export function upShadowSearch(ref, id) {
13
13
  else if (rn === document) {
14
14
  return null;
15
15
  }
16
- return null;
16
+ else if (!rn.isConnected) {
17
+ //TODO: search first for targetFragment
18
+ rn = document;
19
+ }
20
+ //return null;
17
21
  }
18
22
  }
package/upShadowSearch.ts CHANGED
@@ -9,8 +9,12 @@ export function upShadowSearch(ref: Element, id: string){
9
9
  rn = rn.host.getRootNode() as (DocumentFragment | ShadowRoot) & { host?: Element };
10
10
  }else if(rn === document){
11
11
  return null;
12
+ }else if(!rn.isConnected){
13
+ //TODO: search first for targetFragment
14
+ rn = document;
15
+
12
16
  }
13
- return null;
17
+ //return null;
14
18
  }
15
19
  }
16
20