Skip to content

Commit 9810689

Browse files
author
Julien
committed
fix(sdk): Deprecation warning would sometimes cause an Error
1 parent 16fe1b4 commit 9810689

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

engine/modules/entities/src/main/resources/view/entity-module/GraphicEntityModule.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class GraphicEntityModule {
5151
}
5252
}
5353

54-
const parsedFrame = {...frameInfo}
54+
const parsedFrame = { ...frameInfo }
5555

5656
parsedFrame.previous = this.frames[this.frames.length - 1] || parsedFrame
5757

@@ -208,24 +208,28 @@ export class GraphicEntityModule {
208208
api.toWorldUnits = this.globalData.toWorldUnits
209209

210210
// Retro-compatibility
211-
Object.defineProperty(api, 'coeff', {get: () => {
212-
const msg = 'The "coeff" property of GraphicEntityModule\'s API is deprecated, please use "toWorldUnits" instead'
213-
const stack = (new Error).stack
214-
215-
if (console.groupCollapsed) {
216-
console.groupCollapsed(
217-
"%cDeprecation Warning: %c%s",
218-
"color:#614108;background:#fffbe6",
219-
"font-weight:normal;color:#614108;background:#fffbe6",
220-
msg
221-
)
222-
console.warn(stack)
223-
console.groupEnd()
224-
} else {
225-
console.warn("Deprecation Warning: ", msg)
226-
}
211+
if (!api.hasOwnProperty('coeff')) {
212+
Object.defineProperty(api, 'coeff', {
213+
get: () => {
214+
const msg = 'The "coeff" property of GraphicEntityModule\'s API is deprecated, please use "toWorldUnits" instead'
215+
const stack = (new Error()).stack
216+
217+
if (console.groupCollapsed) {
218+
console.groupCollapsed(
219+
'%cDeprecation Warning: %c%s',
220+
'color:#614108;background:#fffbe6',
221+
'font-weight:normal;color:#614108;background:#fffbe6',
222+
msg
223+
)
224+
console.warn(stack)
225+
console.groupEnd()
226+
} else {
227+
console.warn('Deprecation Warning: ', msg)
228+
}
227229

228-
return api.toWorldUnits
229-
}})
230+
return api.toWorldUnits
231+
}
232+
})
233+
}
230234
}
231235
}

0 commit comments

Comments
 (0)