Skip to content

Commit

Permalink
remove attribute if setting value false with asProperty, see #870
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Nov 14, 2018
1 parent 5f7a2cb commit da36ca1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 3 additions & 8 deletions js/accessibility/Accessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -2290,14 +2290,9 @@ define( function( require ) {
if ( this._accessibleChecked !== checked ) {
this._accessibleChecked = checked;

if ( checked ) {
this.setAccessibleAttribute( 'checked', checked, {
asProperty: true
} );
}
else {
this.removeAccessibleAttribute( 'checked' );
}
this.setAccessibleAttribute( 'checked', checked, {
asProperty: true
} );
}
},
set accessibleChecked( checked ) { this.setAccessibleChecked( checked ); },
Expand Down
14 changes: 11 additions & 3 deletions js/accessibility/AccessiblePeer.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,18 @@ define( function( require ) {
element.setAttributeNS( options.namespace, attribute, attributeValue );
}
else if ( options.asProperty ) {
assert && assert( typeof attributeValue === 'boolean', 'value for attribute as property must be boolean' );
if ( attributeValue ) {

// treat it like a property, set in a way that works for elements with a custom namespace (like MathML),
// see https://github.com/phetsims/scenery/issues/870
element.setAttribute( attribute, '' );
// treat it like a property, set in a way that works for elements with a custom namespace (like MathML),
// see https://github.com/phetsims/scenery/issues/870
element.setAttribute( attribute, '' );
}
else {

// support false so that setting property attribute false will remove attribute
element.removeAttribute( attribute );
}
}
else {
element.setAttribute( attribute, attributeValue );
Expand Down

0 comments on commit da36ca1

Please sign in to comment.