DEV: makes aria-expanded boolean check strict (#12008)

{{d-button ariaExpanded=xxx}} only accepts Boolean now.
This commit is contained in:
Joffrey JAFFEUX 2021-02-08 11:18:39 +01:00 committed by GitHub
parent 821bb1e8cb
commit 898772787c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -96,7 +96,12 @@ export default Component.extend({
@discourseComputed("ariaExpanded") @discourseComputed("ariaExpanded")
computedAriaExpanded(ariaExpanded) { computedAriaExpanded(ariaExpanded) {
return ariaExpanded ? "true" : "false"; if (ariaExpanded === true) {
return "true";
}
if (ariaExpanded === false) {
return "false";
}
}, },
click(event) { click(event) {

View File

@ -206,10 +206,12 @@ discourseModule("Integration | Component | d-button", function (hooks) {
}, },
}); });
componentTest("ariaExpanded", { componentTest("aria-expanded", {
template: "{{d-button ariaExpanded=ariaExpanded}}", template: hbs`{{d-button ariaExpanded=ariaExpanded}}`,
test(assert) { test(assert) {
assert.equal(query("button").ariaExpanded, null);
this.set("ariaExpanded", true); this.set("ariaExpanded", true);
assert.equal(query("button").ariaExpanded, "true"); assert.equal(query("button").ariaExpanded, "true");
@ -220,16 +222,16 @@ discourseModule("Integration | Component | d-button", function (hooks) {
this.set("ariaExpanded", "false"); this.set("ariaExpanded", "false");
assert.equal(query("button").ariaExpanded, "true"); assert.equal(query("button").ariaExpanded, null);
this.set("ariaExpanded", "true"); this.set("ariaExpanded", "true");
assert.equal(query("button").ariaExpanded, "true"); assert.equal(query("button").ariaExpanded, null);
}, },
}); });
componentTest("ariaControls", { componentTest("aria-controls", {
template: "{{d-button ariaControls=ariaControls}}", template: hbs`{{d-button ariaControls=ariaControls}}`,
test(assert) { test(assert) {
this.set("ariaControls", "foo-bar"); this.set("ariaControls", "foo-bar");