FIX: workaround constructor name not available after transpilation (#10623)

This is only reproducible en production build. In this case, constructor.name could be any value like "i" for example.
This commit is contained in:
Joffrey JAFFEUX 2020-09-08 10:14:41 +02:00 committed by GitHub
parent a1d135f12a
commit 02495510e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,7 @@ export function decorateWidget(widgetName, cb) {
}
export function traverseCustomWidgets(tree, callback) {
if (tree.constructor.name === "CustomWidget") {
if (tree.__type === "CustomWidget") {
callback(tree);
}
@ -71,6 +71,11 @@ export function changeSetting(widgetName, settingName, newValue) {
export function createWidgetFrom(base, name, opts) {
const result = class CustomWidget extends base {};
// todo this shouldn't been needed anymore once we don't transpile for IE anymore
// see: https://discuss.emberjs.com/t/constructor-name-behaves-differently-in-dev-and-prod-builds-for-models-defined-with-the-es6-class-syntax/15572/6
// once done, we can just check on constructor.name
result.prototype.__type = "CustomWidget";
if (name) {
_registry[name] = result;
}