@lwrjs/client-modules 0.10.0-alpha.6 → 0.10.0-alpha.7

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 +1 @@
1
- import{BOOTSTRAP_END as e}from"lwr/metrics";import{logOperationStart as t}from"lwr/profiler";import{hydrateComponent as o,createElement as r}from"lwc";function n(e,t){return r(e,{is:t})}function c(e){return e.replace(/\/v\/[a-zA-Z0-9-_.]+$/,"").replace("/","-").replace(/([A-Z])/g,(e=>`-${e.toLowerCase()}`))}const l=/-([a-z])/g;function d(e){return e.replace(l,(e=>e[1].toUpperCase()))}function i(r,l={}){if("undefined"!=typeof customElements&&"undefined"!=typeof document){const e=document.querySelector("[lwr-root]");r.forEach((([t,r])=>{const i=c(t);let p=document.body.querySelector(i);if(p){document.querySelectorAll(i).forEach((e=>{const t=e.dataset.lwrPropsId;if(t){const n=l[t]||{};o(e,r,n)}else{const t=n(i,r);for(const{name:o,value:r}of e.attributes){t.setAttribute(o,r);const e=d(o);e in t&&(t[e]=r)}for(;e.childNodes.length>0;)t.appendChild(e.childNodes[0]);e.parentElement.replaceChild(t,e)}}))}else p=n(i,r),e?e.appendChild(p):document.body.appendChild(p)}))}t({id:e})}export{d as getPropFromAttrName,i as init,c as toKebabCase};
1
+ import{BOOTSTRAP_END as e}from"lwr/metrics";import{logOperationStart as t}from"lwr/profiler";import*as o from"lwc";function r(e,t){return o.createElement(e,{is:t})}function n(e){return e.replace(/\/v\/[a-zA-Z0-9-_.]+$/,"").replace("/","-").replace(/([A-Z])/g,(e=>`-${e.toLowerCase()}`))}const c=/-([a-z])/g;function l(e){return e.replace(c,(e=>e[1].toUpperCase()))}function i(c,i={}){if("undefined"!=typeof customElements&&"undefined"!=typeof document){const e=document.querySelector("[lwr-root]");c.forEach((([t,c])=>{const d=n(t);let s=document.body.querySelector(d);if(s){document.querySelectorAll(d).forEach((e=>{const t=e.dataset.lwrPropsId;if(t){const r=i[t]||{};o.hydrateComponent(e,c,r)}else{const t=r(d,c);for(const{name:o,value:r}of e.attributes){t.setAttribute(o,r);const e=l(o);e in t&&(t[e]=r)}for(;e.childNodes.length>0;)t.appendChild(e.childNodes[0]);e.parentElement?e.parentElement.replaceChild(t,e):console&&console.error("[lwr/init] parentElement not set: %o",e)}}))}else s=r(d,c),e?e.appendChild(s):document.body.appendChild(s)}))}t({id:e})}export{l as getPropFromAttrName,i as init,n as toKebabCase};
@@ -1,12 +1,16 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore
1
3
  import { BOOTSTRAP_END } from 'lwr/metrics';
2
- import { logOperationStart } from 'lwr/profiler';
3
-
4
- // TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted
5
4
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
5
  // @ts-ignore
7
- import { createElement, hydrateComponent } from 'lwc';
6
+ import { logOperationStart } from 'lwr/profiler';
7
+
8
+ // TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted - tmp
9
+ import * as lwc from 'lwc';
8
10
  function initializeWebComponent(elementName, Ctor) {
9
- return createElement(elementName, {
11
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
+ // @ts-ignore
13
+ return lwc.createElement(elementName, {
10
14
  is: Ctor
11
15
  });
12
16
  }
@@ -70,7 +74,9 @@ export function init(rootModules, ssrProps = {}) {
70
74
  if (propsId) {
71
75
  // Hydrate an SSRed component
72
76
  const props = ssrProps[propsId] || {};
73
- hydrateComponent(customElement, ctor, props);
77
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
78
+ // @ts-ignore
79
+ lwc.hydrateComponent(customElement, ctor, props);
74
80
  } else {
75
81
  // Create a CSRed component
76
82
  const newElement = initializeWebComponent(elementName, ctor);
@@ -90,7 +96,11 @@ export function init(rootModules, ssrProps = {}) {
90
96
  while (customElement.childNodes.length > 0) {
91
97
  newElement.appendChild(customElement.childNodes[0]);
92
98
  }
93
- customElement.parentElement.replaceChild(newElement, customElement);
99
+ if (customElement.parentElement) {
100
+ customElement.parentElement.replaceChild(newElement, customElement);
101
+ } else if (console) {
102
+ console.error(`[lwr/init] parentElement not set: %o`, customElement);
103
+ }
94
104
  }
95
105
  });
96
106
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.10.0-alpha.6",
7
+ "version": "0.10.0-alpha.7",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@locker/sandbox": "0.19.0",
35
- "@lwrjs/shared-utils": "0.10.0-alpha.6"
35
+ "@lwrjs/shared-utils": "0.10.0-alpha.7"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@rollup/plugin-node-resolve": "^15.0.2",
@@ -63,5 +63,5 @@
63
63
  "volta": {
64
64
  "extends": "../../../package.json"
65
65
  },
66
- "gitHead": "9592d07bd5204eb85c9cb8b576e2a267a798ce00"
66
+ "gitHead": "433dfb2be122a18ff6eddd39e05279f734de0e37"
67
67
  }