DEV: allows this.get in widgets (#8571)

This commit is contained in:
Joffrey JAFFEUX 2019-12-17 18:39:51 +01:00 committed by GitHub
parent 1c7305c0f1
commit 007652ece5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -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;

View File

@ -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");
}
});