mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Correctly render data- attributes in widget hbs templates (#10376)
In virtualdom, element 'properties' are not completely synonymous with element 'attributes'. In particular, `data-` properties will not be rendered as attributes. To ensure all attributes are passed through, we need to include them under an `attributes` key. For more info, see https://github.com/Matt-Esch/virtual-dom/blob/master/docs/vnode.md#custom-attributes-data-
This commit is contained in:
@@ -58,6 +58,20 @@ widgetTest("hbs template - with tagName", {
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest("hbs template - with data attributes", {
|
||||
template: `{{mount-widget widget="hbs-test" args=args}}`,
|
||||
|
||||
beforeEach() {
|
||||
createWidget("hbs-test", {
|
||||
template: hbs`<div class='mydiv' data-my-test='hello world'></div>`
|
||||
});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.equal(find("div.mydiv").data("my-test"), "hello world");
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest("buildClasses", {
|
||||
template: `{{mount-widget widget="classname-test" args=args}}`,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user