DEV: allows this.get in widgets (#8571)
This commit is contained in:
parent
1c7305c0f1
commit
007652ece5
|
@ -12,6 +12,7 @@ import { h } from "virtual-dom";
|
|||
import DecoratorHelper from "discourse/widgets/decorator-helper";
|
||||
import { Promise } from "rsvp";
|
||||
import ENV from "discourse-common/config/environment";
|
||||
import { get } from "@ember/object";
|
||||
|
||||
const _registry = {};
|
||||
|
||||
|
@ -150,6 +151,10 @@ export default class Widget {
|
|||
|
||||
destroy() {}
|
||||
|
||||
get(propertyPath) {
|
||||
return get(this, propertyPath);
|
||||
}
|
||||
|
||||
render(prev) {
|
||||
const { dirtyKeys } = this;
|
||||
|
||||
|
|
|
@ -380,3 +380,23 @@ widgetTest("override settings", {
|
|||
assert.equal(find(".settings").text(), "age is 37");
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest("get accessor", {
|
||||
template: `{{mount-widget widget="get-accessor-test"}}`,
|
||||
|
||||
beforeEach() {
|
||||
createWidget("get-accessor-test", {
|
||||
tagName: "div.test",
|
||||
template: hbs`Hello {{transformed.name}}`,
|
||||
transform() {
|
||||
return {
|
||||
name: this.get("currentUser.username")
|
||||
};
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(find("div.test").text(), "Hello eviltrout");
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue