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")
computedAriaExpanded(ariaExpanded) {
return ariaExpanded ? "true" : "false";
if (ariaExpanded === true) {
return "true";
}
if (ariaExpanded === false) {
return "false";
}
},
click(event) {

View File

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