mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:40:00 +08:00
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:
parent
a1d135f12a
commit
02495510e8
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user