Skip to content

Commit

Permalink
bug fixes, support #715
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jun 16, 2018
1 parent 79ffa41 commit 7273259
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
12 changes: 0 additions & 12 deletions js/accessibility/Accessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,9 @@ define( function( require ) {

var INPUT_TAG = AccessibilityUtil.TAGS.INPUT;
var LABEL_TAG = AccessibilityUtil.TAGS.LABEL;
var DIV_TAG = AccessibilityUtil.TAGS.DIV;
var P_TAG = AccessibilityUtil.TAGS.P;

// default tag names for siblings
var DEFAULT_CONTAINER_TAG_NAME = DIV_TAG;
var DEFAULT_DESCRIPTION_TAG_NAME = P_TAG;
var DEFAULT_LABEL_TAG_NAME = P_TAG;

Expand Down Expand Up @@ -790,11 +788,6 @@ define( function( require ) {
if ( tagName !== this._labelTagName ) {
this._labelTagName = tagName;

// to have a label sibling, you need a container
if ( !this._containerTagName ) {
this.setContainerTagName( DEFAULT_CONTAINER_TAG_NAME );
}

this.invalidateAccessibleContent();
}
},
Expand Down Expand Up @@ -836,11 +829,6 @@ define( function( require ) {

this._descriptionTagName = tagName;

// to have a description sibling, you need a container
if ( !this._containerTagName ) {
this.setContainerTagName( DEFAULT_CONTAINER_TAG_NAME );
}

this.invalidateAccessibleContent();
}
},
Expand Down
17 changes: 3 additions & 14 deletions js/accessibility/AccessibilityUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,9 @@ define( function( require ) {
removeElements: function( element, childrenToRemove ) {

for ( var i = 0; i < childrenToRemove.length; i++ ) {
var childToRemove = element[ i ];

// TODO: very inefficient error checking, n^2 time, uh oh
if ( assert ) {

var hasChild = false;
for ( var j = 0; j < element.childNodes; j++ ) {
var child = element[ j ];
if ( child === childToRemove ) {
hasChild = true;
}
}
assert( hasChild, 'element does not contain child to be removed: ', child );
}
var childToRemove = childrenToRemove[ i ];

assert && assert( element.contains( childToRemove), 'element does not contain child to be removed: ', childToRemove );

element.removeChild( childToRemove );
}
Expand Down
13 changes: 5 additions & 8 deletions js/accessibility/AccessiblePeer.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,12 @@ define( function( require ) {
assert && assert( this.topLevelElements.indexOf( contentElement ) >= 0, 'element is not part of this peer, thus cannot be arranged' );

// keep this.topLevelElements in sync
this.topLevelElements = this.topLevelElements.splice( this.topLevelElements.indexOf( contentElement ), 1 );

var indexOffset = appendElement ? 1 : -1;
indexOffset = indexOffset < 0 ? 0 : indexOffset; //support primarySibling in the first position
this.topLevelElements = this.topLevelElements.splice( this.topLevelElements.indexOf( this.primarySibling ) + indexOffset, contentElement );


// TODO tell the parent that things changed. DO WE NEED TO DO THIS? BECAUSE I THINK THAT THIS IS ALWAYS CALLED BEFORE THE PEER IS ADDED TO THE INSTANCE AND SORTED
this.topLevelElements.splice( this.topLevelElements.indexOf( contentElement ), 1 );

var indexOffset = appendElement ? 1 : 0;
var indexOfContentElement = this.topLevelElements.indexOf( this.primarySibling ) + indexOffset;
indexOfContentElement = indexOfContentElement < 0 ? 0 : indexOfContentElement; //support primarySibling in the first position
this.topLevelElements.splice( indexOfContentElement, 0, contentElement );
}
},

Expand Down

0 comments on commit 7273259

Please sign in to comment.