@startinblox/boilerplate 4.2.0 → 4.2.1

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/dist/index.js CHANGED
@@ -691,13 +691,13 @@ class $ extends lt {
691
691
  } = {}) {
692
692
  super(), this.cherryPickedProperties = [], this.currentRoute = "";
693
693
  const i = () => {
694
- this._attach(t, e, r).then(
694
+ document.readyState === "complete" && this._attach(t, e, r).then(
695
695
  (o) => {
696
696
  o && this.requestUpdate();
697
697
  }
698
698
  );
699
699
  };
700
- document.readyState !== "complete" ? document.addEventListener("DOMContentLoaded", i) : i();
700
+ document.addEventListener("readystatechange", i);
701
701
  }
702
702
  async _attach(t, e, r) {
703
703
  return !this.orbit && window.orbit && (this.orbit = window.orbit, e) ? (be({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/boilerplate",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "Startin'blox Boilerplate",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -23,19 +23,17 @@ export default class extends ComponentObjectsHandler {
23
23
  } = {}) {
24
24
  super();
25
25
  const attach = () => {
26
- this._attach(defaultRoute, setupSubscriptions, ignoreRouter).then(
27
- (attach: boolean) => {
28
- if (attach) {
29
- this.requestUpdate();
26
+ if (document.readyState === "complete") {
27
+ this._attach(defaultRoute, setupSubscriptions, ignoreRouter).then(
28
+ (attach: boolean) => {
29
+ if (attach) {
30
+ this.requestUpdate();
31
+ }
30
32
  }
31
- },
32
- );
33
+ );
34
+ }
33
35
  };
34
- if (document.readyState !== "complete") {
35
- document.addEventListener("DOMContentLoaded", attach);
36
- } else {
37
- attach();
38
- }
36
+ document.addEventListener("readystatechange", attach);
39
37
  }
40
38
 
41
39
  @property({ attribute: "default-data-src", reflect: true })
@@ -65,7 +63,7 @@ export default class extends ComponentObjectsHandler {
65
63
  protected async _attach(
66
64
  defaultRoute: boolean,
67
65
  setupSubscriptions: boolean,
68
- ignoreRouter: boolean,
66
+ ignoreRouter: boolean
69
67
  ) {
70
68
  if (!this.orbit) {
71
69
  if (window.orbit) {
@@ -109,7 +107,7 @@ export default class extends ComponentObjectsHandler {
109
107
  const rdfType = navigator.getAttribute("navigation-rdf-type");
110
108
  if (rdfType) {
111
109
  const compatibleComponents = window.orbit?.components?.filter(
112
- (c) => c?.routeAttributes?.["rdf-type"] === rdfType,
110
+ (c) => c?.routeAttributes?.["rdf-type"] === rdfType
113
111
  );
114
112
  if (compatibleComponents) target = compatibleComponents[0]?.uniq;
115
113
  }
@@ -117,7 +115,7 @@ export default class extends ComponentObjectsHandler {
117
115
  requestNavigation(
118
116
  (window.orbit ? window.orbit.getRoute(target, true) : target) +
119
117
  (subrouter ? `-${subrouter}` : ""),
120
- resource,
118
+ resource
121
119
  );
122
120
  }
123
121
  e.preventDefault();
@@ -132,7 +130,7 @@ export default class extends ComponentObjectsHandler {
132
130
 
133
131
  async _expandContainer(
134
132
  value: Resource[],
135
- recursive = true,
133
+ recursive = true
136
134
  ): Promise<UnknownResource[]> {
137
135
  const expandedContainer: UnknownResource[] = [];
138
136
  for (const entry of value) {
@@ -145,7 +143,7 @@ export default class extends ComponentObjectsHandler {
145
143
  async _getProperties(
146
144
  resource: Resource,
147
145
  recursive = true,
148
- targetProperties: PropertiesPicker[] = this.cherryPickedProperties,
146
+ targetProperties: PropertiesPicker[] = this.cherryPickedProperties
149
147
  ) {
150
148
  const properties = await resource.properties;
151
149
  const response: Resource = {
@@ -161,7 +159,7 @@ export default class extends ComponentObjectsHandler {
161
159
  response[prop.value] = await this._getProxyValue(
162
160
  response[prop.value],
163
161
  recursive,
164
- targetProperties,
162
+ targetProperties
165
163
  );
166
164
  }
167
165
  if (prop.cast) {
@@ -178,7 +176,7 @@ export default class extends ComponentObjectsHandler {
178
176
  | Resource
179
177
  | ProxyValue<Resource | Container<ProxyValue<Resource> | Resource>>,
180
178
  recursive = true,
181
- targetProperties: PropertiesPicker[] = this.cherryPickedProperties,
179
+ targetProperties: PropertiesPicker[] = this.cherryPickedProperties
182
180
  ) {
183
181
  try {
184
182
  if (resource) {
@@ -190,7 +188,7 @@ export default class extends ComponentObjectsHandler {
190
188
  if (!resource.isFullResource?.()) {
191
189
  target = await window.sibStore.getData(
192
190
  resource["@id"],
193
- CLIENT_CONTEXT,
191
+ CLIENT_CONTEXT
194
192
  );
195
193
  }
196
194
  }