Skip to content

Commit

Permalink
add element option to AccessiblePeer.setAttributeToElement, use in se…
Browse files Browse the repository at this point in the history
…tVisible, see #895
  • Loading branch information
jessegreenberg committed Nov 14, 2018
1 parent 933dc88 commit e0e6deb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions js/accessibility/AccessiblePeer.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,14 @@ define( function( require ) {
// set as a javascript property instead of an attribute on the DOM Element.
asProperty: false,

elementName: PRIMARY_SIBLING // see this.getElementName() for valid values, default to the primary sibling
elementName: PRIMARY_SIBLING, // see this.getElementName() for valid values, default to the primary sibling

// {HTMLElement|null} - element that will directly receive the input rather than looking up by name, if
// provided, elementName option will have no effect
element: null
}, options );

var element = this.getElementByName( options.elementName );
var element = options.element || this.getElementByName( options.elementName );

if ( options.namespace ) {
element.setAttributeNS( options.namespace, attribute, attributeValue );
Expand All @@ -544,10 +548,14 @@ define( function( require ) {
// for setting certain attributes (e.g. MathML).
namespace: null,

elementName: PRIMARY_SIBLING // see this.getElementName() for valid values, default to the primary sibling
elementName: PRIMARY_SIBLING, // see this.getElementName() for valid values, default to the primary sibling

// {HTMLElement|null} - element that will directly receive the input rather than looking up by name, if
// provided, elementName option will have no effect
element: null
}, options );

var element = this.getElementByName( options.elementName );
var element = options.element || this.getElementByName( options.elementName );

if ( options.namespace ) {
element.removeAttributeNS( options.namespace, attribute );
Expand Down Expand Up @@ -702,10 +710,10 @@ define( function( require ) {
for ( var i = 0; i < this.topLevelElements.length; i++ ) {
var element = this.topLevelElements[ i ];
if ( visible ) {
element.removeAttribute( 'hidden' );
this.removeAttributeFromElement( 'hidden', { element: element } );
}
else {
element.setAttribute( 'hidden', '' );
this.setAttributeToElement( 'hidden', '', { element: element } );
}
}
}
Expand Down

0 comments on commit e0e6deb

Please sign in to comment.