@salesforcedevs/docs-components
Advanced tools
Comparing version 1.3.300-async-fix-alpha4 to 1.3.300-fix-alpha
{ | ||
"name": "@salesforcedevs/docs-components", | ||
"version": "1.3.300-async-fix-alpha4", | ||
"version": "1.3.300-fix-alpha", | ||
"description": "Docs Lightning web components for DSC", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -1481,3 +1481,3 @@ import { LightningElement, api, track } from "lwc"; | ||
type, | ||
amf: this.amfMap[referenceId].model, | ||
amf: JSON.stringify(this.amfMap[referenceId].model), | ||
parser: this.amfMap[referenceId].parser, | ||
@@ -1484,0 +1484,0 @@ id: amfId |
@@ -26,43 +26,22 @@ import { LightningElement, api } from "lwc"; | ||
set model(value: TopicModel) { | ||
const amfNeedsClone = | ||
if ( | ||
!this.amf || | ||
(value && this._model && value.amf !== this._model?.amf); | ||
const typeNeedsClone = | ||
(value && this._model && value.amf !== this._model?.amf) | ||
) { | ||
this.amf = value && JSON.parse(value.amf); | ||
} | ||
if ( | ||
!this.type || | ||
(value && this._model && value.type !== this._model?.type); | ||
(value && this._model && value.type !== this._model?.type) | ||
) { | ||
this.type = value && value.type; | ||
} | ||
this.cloneData( | ||
amfNeedsClone ? value.amf : this.amf, | ||
typeNeedsClone ? value.type : this.type | ||
) | ||
.then(([clonedAmf, clonedType]) => { | ||
this.amf = clonedAmf; | ||
this.type = clonedType; | ||
this._model = value; | ||
this.update(); | ||
}) | ||
.catch((error) => { | ||
console.error("Error cloning model:", error); | ||
}); | ||
this._model = value; | ||
if (this._model) { | ||
this.update(); | ||
} | ||
// else { Remove child? No model, seems like no component should be shown. } | ||
} | ||
async cloneData( | ||
amf: Json | undefined, | ||
type: string | undefined | ||
): Promise<[Json, string]> { | ||
const clonedAmf = amf ? await this.clone(amf) : amf; | ||
const clonedType = type ? await this.clone(type) : type; | ||
return [clonedAmf, clonedType]; | ||
} | ||
async clone(value: any): Promise<any> { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
resolve(JSON.parse(JSON.stringify(value))); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
} | ||
update(): void { | ||
@@ -116,2 +95,3 @@ if (!this.model) { | ||
).matches; | ||
if (isTabletOrDesktop) { | ||
@@ -123,10 +103,18 @@ window.scrollTo(0, 0); | ||
renderedCallback(): void { | ||
if (this._model) { | ||
try { | ||
this.update(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
try { | ||
this.update(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
} | ||
/** | ||
* The underlying web components we use from api-console mutate their models we pass in. | ||
* Since LWC makes them Read Only, we need to copy them before passing to the Web Component. | ||
* @param value JSON Serializable object to clone. | ||
* @returns A copy of Value. One that has been serialized and parsed via JSON. (Functions, Regex, etc are not preserved.) | ||
*/ | ||
// function clone(value: any): any { | ||
// return JSON.parse(JSON.stringify(value)); | ||
// } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
254449
75
6526