FIX: In prod builds classes may not be "instancesof" EmberObject (#18137)

They do have CoreObject in their prototype chain.

Fixes the issue mentioned in https://github.com/discourse/discourse-chat/pull/1204
This commit is contained in:
Jarek Radosz 2022-08-30 17:36:20 +02:00 committed by GitHub
parent 6570fed175
commit af7620cef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1,10 +1,11 @@
import EmberObject, { computed, get } from "@ember/object";
import CoreObject from "@ember/object/core";
import { computed, get } from "@ember/object";
import extractValue from "./extract-value";
export default function handleDescriptor(target, key, desc, params = []) {
const val = extractValue(desc);
if (typeof val === "function" && target instanceof EmberObject) {
if (typeof val === "function" && target instanceof CoreObject) {
// We're in a native class, so convert the method to a getter first
desc.writable = false;
desc.initializer = undefined;