From bea6380eb33497c8471ddae410785430bd2fa667 Mon Sep 17 00:00:00 2001 From: zepumph Date: Thu, 19 Sep 2019 14:26:00 -0800 Subject: [PATCH] var -> const using eslint auto fix, https://github.com/phetsims/tasks/issues/1012 --- js/accessibility/A11yBehaviorFunctionDef.js | 2 +- js/accessibility/Accessibility.js | 200 +++---- js/accessibility/AccessibilityFuzzer.js | 22 +- js/accessibility/AccessibilityTests.js | 492 +++++++++--------- js/accessibility/AccessibilityTree.js | 126 ++--- js/accessibility/AccessibilityUtil.js | 138 ++--- js/accessibility/AccessibilityUtilTests.js | 58 +-- js/accessibility/AccessibleDisplaysInfo.js | 20 +- js/accessibility/AccessibleInstance.js | 100 ++-- js/accessibility/AccessiblePeer.js | 98 ++-- js/accessibility/FocusHighlightFromNode.js | 6 +- js/accessibility/FocusHighlightPath.js | 34 +- js/accessibility/FocusIO.js | 2 +- js/accessibility/FocusTests.js | 228 ++++---- js/accessibility/KeyboardFuzzer.js | 12 +- js/accessibility/KeyboardUtil.js | 14 +- js/accessibility/PartialAccessibleTrail.js | 2 +- js/accessibility/reader/Cursor.js | 228 ++++---- js/accessibility/reader/Reader.js | 18 +- js/display/BackboneDrawable.js | 48 +- js/display/Block.js | 10 +- js/display/CanvasBlock.js | 64 +-- js/display/ChangeInterval.js | 20 +- js/display/Display.js | 198 +++---- js/display/DisplayTests.js | 180 +++---- js/display/Drawable.js | 14 +- js/display/Fittability.js | 14 +- js/display/FittedBlock.js | 12 +- js/display/FuzzTests.js | 94 ++-- js/display/GreedyStitcher.js | 82 +-- js/display/Instance.js | 210 ++++---- js/display/PaintObserver.js | 16 +- js/display/PaintSVGState.js | 16 +- js/display/RebuildStitcher.js | 14 +- js/display/RelativeTransform.js | 66 +-- js/display/Renderer.js | 16 +- js/display/SVGBlock.js | 16 +- js/display/SVGGradient.js | 14 +- js/display/SVGGradientStop.js | 10 +- js/display/SVGGroup.js | 26 +- js/display/SVGPattern.js | 2 +- js/display/SVGSelfDrawable.js | 22 +- js/display/Stitcher.js | 36 +- js/display/WebGLBlock.js | 64 +-- js/display/drawables/CanvasNodeDrawable.js | 4 +- js/display/drawables/CircleCanvasDrawable.js | 2 +- js/display/drawables/CircleDOMDrawable.js | 16 +- js/display/drawables/CircleSVGDrawable.js | 4 +- .../drawables/CircleStatefulDrawable.js | 4 +- js/display/drawables/ImageCanvasDrawable.js | 8 +- js/display/drawables/ImageDOMDrawable.js | 6 +- js/display/drawables/ImageSVGDrawable.js | 12 +- js/display/drawables/ImageStatefulDrawable.js | 4 +- js/display/drawables/ImageWebGLDrawable.js | 36 +- js/display/drawables/LineCanvasDrawable.js | 2 +- js/display/drawables/LineSVGDrawable.js | 4 +- js/display/drawables/LineStatefulDrawable.js | 4 +- js/display/drawables/LineStatelessDrawable.js | 4 +- .../drawables/PaintableStatefulDrawable.js | 4 +- .../drawables/PaintableStatelessDrawable.js | 4 +- js/display/drawables/PathCanvasDrawable.js | 2 +- js/display/drawables/PathSVGDrawable.js | 6 +- js/display/drawables/PathStatefulDrawable.js | 4 +- .../drawables/RectangleCanvasDrawable.js | 16 +- js/display/drawables/RectangleDOMDrawable.js | 22 +- js/display/drawables/RectangleSVGDrawable.js | 10 +- .../drawables/RectangleStatefulDrawable.js | 4 +- .../drawables/RectangleWebGLDrawable.js | 30 +- js/display/drawables/TextCanvasDrawable.js | 2 +- js/display/drawables/TextDOMDrawable.js | 12 +- js/display/drawables/TextSVGDrawable.js | 10 +- js/display/drawables/TextStatefulDrawable.js | 4 +- js/display/drawables/WebGLNodeDrawable.js | 6 +- js/input/BatchedDOMEvent.js | 8 +- js/input/BrowserEvents.js | 26 +- js/input/ButtonListener.js | 4 +- js/input/DownUpListener.js | 8 +- js/input/EventIO.js | 2 +- js/input/Input.js | 24 +- js/input/InputFuzzer.js | 40 +- js/input/Mouse.js | 10 +- js/input/Pen.js | 6 +- js/input/Pointer.js | 8 +- js/input/SimpleDragHandler.js | 18 +- js/input/Touch.js | 6 +- js/listeners/DragListener.js | 10 +- js/listeners/DragListenerTests.js | 20 +- js/listeners/FireListener.js | 4 +- js/listeners/FireListenerTests.js | 4 +- js/listeners/KeyboardDragListener.js | 56 +- js/listeners/ListenerTestUtils.js | 12 +- js/listeners/MultiListener.js | 90 ++-- js/listeners/PanZoomListener.js | 2 +- js/listeners/PressListener.js | 12 +- js/listeners/PressListenerTests.js | 10 +- js/nodes/AlignBox.js | 12 +- js/nodes/AlignBoxTests.js | 16 +- js/nodes/AlignGroup.js | 16 +- js/nodes/CanvasNode.js | 4 +- js/nodes/Circle.js | 28 +- js/nodes/DOM.js | 8 +- js/nodes/Image.js | 70 +-- js/nodes/ImageIO.js | 2 +- js/nodes/LayoutBox.js | 40 +- js/nodes/Leaf.js | 4 +- js/nodes/Line.js | 54 +- js/nodes/Node.js | 322 ++++++------ js/nodes/NodeIO.js | 6 +- js/nodes/NodeTests.js | 40 +- js/nodes/Paintable.js | 84 +-- js/nodes/Path.js | 18 +- js/nodes/Rectangle.js | 84 +-- js/nodes/RichText.js | 122 ++--- js/nodes/RichTextIO.js | 2 +- js/nodes/ShapeTests.js | 124 ++--- js/nodes/Text.js | 66 +-- js/nodes/TextIO.js | 2 +- js/nodes/WebGLNode.js | 22 +- js/overlays/CanvasNodeBoundsOverlay.js | 6 +- js/overlays/FittedBlockBoundsOverlay.js | 4 +- js/overlays/FocusOverlay.js | 24 +- js/overlays/PointerAreaOverlay.js | 6 +- js/overlays/PointerOverlay.js | 18 +- js/overlays/ShapeBasedOverlay.js | 6 +- js/scenery.js | 68 +-- js/tests/MiscellaneousTests.js | 16 +- js/tests/PixelComparisonTests.js | 122 ++--- js/tests/snapshotEquals.js | 30 +- js/util/Color.js | 98 ++-- js/util/ColorDef.js | 2 +- js/util/ColorTests.js | 32 +- js/util/Features.js | 26 +- js/util/Font.js | 20 +- js/util/FontTests.js | 4 +- js/util/FullScreen.js | 12 +- js/util/Gradient.js | 8 +- js/util/LinearGradient.js | 4 +- js/util/Paint.js | 2 +- js/util/PaintDef.js | 4 +- js/util/Picker.js | 84 +-- js/util/RadialGradient.js | 12 +- js/util/RendererSummary.js | 76 +-- js/util/SceneImage.js | 4 +- js/util/SceneryStyle.js | 4 +- js/util/ShaderProgram.js | 6 +- js/util/SpriteSheet.js | 32 +- js/util/TextBounds.js | 50 +- js/util/Trail.js | 178 +++---- js/util/TrailPointer.js | 22 +- js/util/TrailTests.js | 186 +++---- js/util/TransformTracker.js | 26 +- js/util/Util.js | 96 ++-- tests/browsers/unicode/inline-js-unicode.js | 2 +- tests/event-logs/server/server.js | 8 +- tests/webgl/LinesRenderer.js | 4 +- 155 files changed, 3069 insertions(+), 3069 deletions(-) diff --git a/js/accessibility/A11yBehaviorFunctionDef.js b/js/accessibility/A11yBehaviorFunctionDef.js index ac6100458..991044eb5 100644 --- a/js/accessibility/A11yBehaviorFunctionDef.js +++ b/js/accessibility/A11yBehaviorFunctionDef.js @@ -21,7 +21,7 @@ define( require => { * @param {string} value - the value that you are setting the behavior of, like the accessibleName * @returns {Object} - the options that have been mutated by the behavior function. */ - var A11yBehaviorFunctionDef = { + const A11yBehaviorFunctionDef = { /** * Will assert out if the behavior function doesn't match the expected features of A11yBehaviorFunction diff --git a/js/accessibility/Accessibility.js b/js/accessibility/Accessibility.js index ef90bf416..a3a7994b2 100644 --- a/js/accessibility/Accessibility.js +++ b/js/accessibility/Accessibility.js @@ -133,15 +133,15 @@ define( require => { const scenery = require( 'SCENERY/scenery' ); const Shape = require( 'KITE/Shape' ); - var INPUT_TAG = AccessibilityUtil.TAGS.INPUT; - var P_TAG = AccessibilityUtil.TAGS.P; + const INPUT_TAG = AccessibilityUtil.TAGS.INPUT; + const P_TAG = AccessibilityUtil.TAGS.P; // default tag names for siblings - var DEFAULT_DESCRIPTION_TAG_NAME = P_TAG; - var DEFAULT_LABEL_TAG_NAME = P_TAG; + const DEFAULT_DESCRIPTION_TAG_NAME = P_TAG; + const DEFAULT_LABEL_TAG_NAME = P_TAG; // see setAccessibleNameBehavior for more details - var DEFAULT_ACCESSIBLE_NAME_BEHAVIOR = function( node, options, accessibleName ) { + const DEFAULT_ACCESSIBLE_NAME_BEHAVIOR = function( node, options, accessibleName ) { if ( node.tagName === 'input' ) { options.labelTagName = 'label'; options.labelContent = accessibleName; @@ -156,7 +156,7 @@ define( require => { }; // see setHelpTextBehavior for more details - var DEFAULT_HELP_TEXT_BEHAVIOR = function( node, options, helpText ) { + const DEFAULT_HELP_TEXT_BEHAVIOR = function( node, options, helpText ) { options.descriptionTagName = AccessibilityUtil.DEFAULT_DESCRIPTION_TAG_NAME; options.descriptionContent = helpText; @@ -165,7 +165,7 @@ define( require => { }; // see setAccessibleHeadingBehavior for more details - var DEFAULT_ACCESSIBLE_HEADING_BEHAVIOR = function( node, options, heading ) { + const DEFAULT_ACCESSIBLE_HEADING_BEHAVIOR = function( node, options, heading ) { options.labelTagName = 'h' + node.headingLevel; // TODO: make sure heading level change fires a full peer rebuild, see https://github.com/phetsims/scenery/issues/867 options.labelContent = heading; @@ -173,17 +173,17 @@ define( require => { }; // these elements are typically associated with forms, and support certain attributes - var FORM_ELEMENTS = AccessibilityUtil.FORM_ELEMENTS; + const FORM_ELEMENTS = AccessibilityUtil.FORM_ELEMENTS; // list of input "type" attribute values that support the "checked" attribute - var INPUT_TYPES_THAT_SUPPORT_CHECKED = AccessibilityUtil.INPUT_TYPES_THAT_SUPPORT_CHECKED; + const INPUT_TYPES_THAT_SUPPORT_CHECKED = AccessibilityUtil.INPUT_TYPES_THAT_SUPPORT_CHECKED; // HTMLElement attributes whose value is an ID of another element - var ASSOCIATION_ATTRIBUTES = AccessibilityUtil.ASSOCIATION_ATTRIBUTES; + const ASSOCIATION_ATTRIBUTES = AccessibilityUtil.ASSOCIATION_ATTRIBUTES; // The options for the Accessibility API. In general, most default to null; to clear, set back to null. Each one of // these has an associated setter, see setter functions for more information about each. - var ACCESSIBILITY_OPTION_KEYS = [ + const ACCESSIBILITY_OPTION_KEYS = [ // Order matters. Having focus before tagName covers the case where you change the tagName and focusability of a // currently focused node. We want the focusability to update correctly. @@ -233,7 +233,7 @@ define( require => { 'activeDescendantAssociations' // {Array.} - sets the list of aria-activedescendant associations between from this node to others (including itself) ]; - var Accessibility = { + const Accessibility = { /** * Given the constructor for Node, add accessibility functions into the prototype. @@ -242,7 +242,7 @@ define( require => { */ compose: function( type ) { // Can't avoid circular dependency, so no assertion here. Ensure that 'type' is the constructor for Node. - var proto = type.prototype; + const proto = type.prototype; /** * These properties and methods are put directly on the prototype of Node. @@ -481,8 +481,8 @@ define( require => { * @returns {boolean} */ isFocused: function() { - for ( var i = 0; i < this._accessibleInstances.length; i++ ) { - var peer = this._accessibleInstances[ i ].peer; + for ( let i = 0; i < this._accessibleInstances.length; i++ ) { + const peer = this._accessibleInstances[ i ].peer; if ( peer.isFocused() ) { return true; } @@ -511,7 +511,7 @@ define( require => { assert && assert( this._accessibleVisible, 'trying to set focus on a node with invisible accessible content' ); assert && assert( this._accessibleInstances.length === 1, 'focus() unsupported for Nodes using DAG, accessible content is not unique' ); - var peer = this._accessibleInstances[ 0 ].peer; + const peer = this._accessibleInstances[ 0 ].peer; assert && assert( peer, 'must have a peer to focus' ); peer.focus(); } @@ -525,7 +525,7 @@ define( require => { blur: function() { if ( this._accessibleInstances.length > 0 ) { assert && assert( this._accessibleInstances.length === 1, 'blur() unsupported for Nodes using DAG, accessible content is not unique' ); - var peer = this._accessibleInstances[ 0 ].peer; + const peer = this._accessibleInstances[ 0 ].peer; assert && assert( peer, 'must have a peer to blur' ); peer.blur(); this.interruptInput(); // interrupt any listeners that attached to this Node @@ -746,7 +746,7 @@ define( require => { } if ( this._accessibleHeading ) { - var level = this._accessibleParent.computeHeadingLevel() + 1; + const level = this._accessibleParent.computeHeadingLevel() + 1; this._headingLevel = level; return level; } @@ -950,8 +950,8 @@ define( require => { if ( inputType !== this._inputType ) { this._inputType = inputType; - for ( var i = 0; i < this._accessibleInstances.length; i++ ) { - var peer = this._accessibleInstances[ i ].peer; + for ( let i = 0; i < this._accessibleInstances.length; i++ ) { + const peer = this._accessibleInstances[ i ].peer; // remove the attribute if cleared by setting to 'null' if ( inputType === null ) { @@ -1119,8 +1119,8 @@ define( require => { this.setLabelTagName( DEFAULT_LABEL_TAG_NAME ); } - for ( var i = 0; i < this._accessibleInstances.length; i++ ) { - var peer = this._accessibleInstances[ i ].peer; + for ( let i = 0; i < this._accessibleInstances.length; i++ ) { + const peer = this._accessibleInstances[ i ].peer; peer.setLabelSiblingContent( this._labelContent ); } } @@ -1152,8 +1152,8 @@ define( require => { if ( this._innerContent !== content ) { this._innerContent = content; - for ( var i = 0; i < this._accessibleInstances.length; i++ ) { - var peer = this._accessibleInstances[ i ].peer; + for ( let i = 0; i < this._accessibleInstances.length; i++ ) { + const peer = this._accessibleInstances[ i ].peer; peer.setPrimarySiblingContent( this._innerContent ); } } @@ -1190,8 +1190,8 @@ define( require => { this.setDescriptionTagName( DEFAULT_DESCRIPTION_TAG_NAME ); } - for ( var i = 0; i < this._accessibleInstances.length; i++ ) { - var peer = this._accessibleInstances[ i ].peer; + for ( let i = 0; i < this._accessibleInstances.length; i++ ) { + const peer = this._accessibleInstances[ i ].peer; peer.setDescriptionSiblingContent( this._descriptionContent ); } } @@ -1513,8 +1513,8 @@ define( require => { * @param {Array.} ariaLabelledbyAssociations - list of associationObjects, see this._ariaLabelledbyAssociations. */ setAriaLabelledbyAssociations: function( ariaLabelledbyAssociations ) { - var associationObject; - var i; + let associationObject; + let i; // validation if assert is enabled if ( assert ) { @@ -1528,9 +1528,9 @@ define( require => { // if the list isn't the same, TODO: make order in the list not matter, perhaps with sorting? https://stackoverflow.com/questions/29951293/using-lodash-to-compare-arrays-items-existence-without-order if ( !_.isEqual( ariaLabelledbyAssociations, this._ariaLabelledbyAssociations ) ) { - var beforeOnly = []; // Will hold all nodes that will be removed. - var afterOnly = []; // Will hold all nodes that will be "new" children (added) - var inBoth = []; // Child nodes that "stay". Will be ordered for the "after" case. + const beforeOnly = []; // Will hold all nodes that will be removed. + const afterOnly = []; // Will hold all nodes that will be "new" children (added) + const inBoth = []; // Child nodes that "stay". Will be ordered for the "after" case. // get a difference of the desired new list, and the old arrayDifference( ariaLabelledbyAssociations, this._ariaLabelledbyAssociations, afterOnly, beforeOnly, inBoth ); @@ -1546,7 +1546,7 @@ define( require => { // add each association from the new list that hasn't been added yet for ( i = 0; i < afterOnly.length; i++ ) { - var ariaLabelledbyAssociation = ariaLabelledbyAssociations[ i ]; + const ariaLabelledbyAssociation = ariaLabelledbyAssociations[ i ]; this.addAriaLabelledbyAssociation( ariaLabelledbyAssociation ); } @@ -1600,7 +1600,7 @@ define( require => { assert && assert( _.includes( this._ariaLabelledbyAssociations, associationObject ) ); // remove the - var removedObject = this._ariaLabelledbyAssociations.splice( _.indexOf( this._ariaLabelledbyAssociations, associationObject ), 1 ); + const removedObject = this._ariaLabelledbyAssociations.splice( _.indexOf( this._ariaLabelledbyAssociations, associationObject ), 1 ); // remove the reference from the other node back to this node because we don't need it anymore removedObject[ 0 ].otherNode.removeNodeThatIsAriaLabelledByThisNode( this ); @@ -1615,7 +1615,7 @@ define( require => { */ removeNodeThatIsAriaLabelledByThisNode: function( node ) { assert && assert( node instanceof scenery.Node ); - var indexOfNode = _.indexOf( this._nodesThatAreAriaLabelledbyThisNode, node ); + const indexOfNode = _.indexOf( this._nodesThatAreAriaLabelledbyThisNode, node ); assert && assert( indexOfNode >= 0 ); this._nodesThatAreAriaLabelledbyThisNode.splice( indexOfNode, 1 ); }, @@ -1625,8 +1625,8 @@ define( require => { * @public */ updateAriaLabelledbyAssociationsInPeers: function() { - for ( var i = 0; i < this.accessibleInstances.length; i++ ) { - var peer = this.accessibleInstances[ i ].peer; + for ( let i = 0; i < this.accessibleInstances.length; i++ ) { + const peer = this.accessibleInstances[ i ].peer; peer.onAriaLabelledbyAssociationChange(); } }, @@ -1639,8 +1639,8 @@ define( require => { // if any other nodes are aria-labelledby this Node, update those associations too. Since this node's // accessible content needs to be recreated, they need to update their aria-labelledby associations accordingly. - for ( var i = 0; i < this._nodesThatAreAriaLabelledbyThisNode.length; i++ ) { - var otherNode = this._nodesThatAreAriaLabelledbyThisNode[ i ]; + for ( let i = 0; i < this._nodesThatAreAriaLabelledbyThisNode.length; i++ ) { + const otherNode = this._nodesThatAreAriaLabelledbyThisNode[ i ]; otherNode.updateAriaLabelledbyAssociationsInPeers(); } }, @@ -1662,10 +1662,10 @@ define( require => { * @param {Array.} ariaDescribedbyAssociations - list of associationObjects, see this._ariaDescribedbyAssociations. */ setAriaDescribedbyAssociations: function( ariaDescribedbyAssociations ) { - var associationObject; + let associationObject; if ( assert ) { assert( Array.isArray( ariaDescribedbyAssociations ) ); - for ( var j = 0; j < ariaDescribedbyAssociations.length; j++ ) { + for ( let j = 0; j < ariaDescribedbyAssociations.length; j++ ) { associationObject = ariaDescribedbyAssociations[ j ]; assert && AccessibilityUtil.validateAssociationObject( associationObject ); } @@ -1674,10 +1674,10 @@ define( require => { // if the list isn't the same, TODO: make order in the list not matter if ( !_.isEqual( ariaDescribedbyAssociations, this._ariaDescribedbyAssociations ) ) { - var beforeOnly = []; // Will hold all nodes that will be removed. - var afterOnly = []; // Will hold all nodes that will be "new" children (added) - var inBoth = []; // Child nodes that "stay". Will be ordered for the "after" case. - var i; + const beforeOnly = []; // Will hold all nodes that will be removed. + const afterOnly = []; // Will hold all nodes that will be "new" children (added) + const inBoth = []; // Child nodes that "stay". Will be ordered for the "after" case. + let i; // get a difference of the desired new list, and the old arrayDifference( ariaDescribedbyAssociations, this._ariaDescribedbyAssociations, afterOnly, beforeOnly, inBoth ); @@ -1693,7 +1693,7 @@ define( require => { // add each association from the new list that hasn't been added yet for ( i = 0; i < afterOnly.length; i++ ) { - var ariaDescribedbyAssociation = ariaDescribedbyAssociations[ i ]; + const ariaDescribedbyAssociation = ariaDescribedbyAssociations[ i ]; this.addAriaDescribedbyAssociation( ariaDescribedbyAssociation ); } @@ -1746,7 +1746,7 @@ define( require => { assert && assert( _.includes( this._ariaDescribedbyAssociations, associationObject ) ); // remove the - var removedObject = this._ariaDescribedbyAssociations.splice( _.indexOf( this._ariaDescribedbyAssociations, associationObject ), 1 ); + const removedObject = this._ariaDescribedbyAssociations.splice( _.indexOf( this._ariaDescribedbyAssociations, associationObject ), 1 ); // remove the reference from the other node back to this node because we don't need it anymore removedObject[ 0 ].otherNode.removeNodeThatIsAriaDescribedByThisNode( this ); @@ -1761,7 +1761,7 @@ define( require => { */ removeNodeThatIsAriaDescribedByThisNode: function( node ) { assert && assert( node instanceof scenery.Node ); - var indexOfNode = _.indexOf( this._nodesThatAreAriaDescribedbyThisNode, node ); + const indexOfNode = _.indexOf( this._nodesThatAreAriaDescribedbyThisNode, node ); assert && assert( indexOfNode >= 0 ); this._nodesThatAreAriaDescribedbyThisNode.splice( indexOfNode, 1 ); @@ -1772,8 +1772,8 @@ define( require => { * @public */ updateAriaDescribedbyAssociationsInPeers: function() { - for ( var i = 0; i < this.accessibleInstances.length; i++ ) { - var peer = this.accessibleInstances[ i ].peer; + for ( let i = 0; i < this.accessibleInstances.length; i++ ) { + const peer = this.accessibleInstances[ i ].peer; peer.onAriaDescribedbyAssociationChange(); } }, @@ -1787,8 +1787,8 @@ define( require => { // if any other nodes are aria-describedby this Node, update those associations too. Since this node's // accessible content needs to be recreated, they need to update their aria-describedby associations accordingly. // TODO: only use unique elements of the array (_.unique) - for ( var i = 0; i < this._nodesThatAreAriaDescribedbyThisNode.length; i++ ) { - var otherNode = this._nodesThatAreAriaDescribedbyThisNode[ i ]; + for ( let i = 0; i < this._nodesThatAreAriaDescribedbyThisNode.length; i++ ) { + const otherNode = this._nodesThatAreAriaDescribedbyThisNode[ i ]; otherNode.updateAriaDescribedbyAssociationsInPeers(); } }, @@ -1810,10 +1810,10 @@ define( require => { * @param {Array.} activeDescendantAssociations - list of associationObjects, see this._activeDescendantAssociations. */ setActiveDescendantAssociations: function( activeDescendantAssociations ) { - var associationObject; + let associationObject; if ( assert ) { assert( Array.isArray( activeDescendantAssociations ) ); - for ( var j = 0; j < activeDescendantAssociations.length; j++ ) { + for ( let j = 0; j < activeDescendantAssociations.length; j++ ) { associationObject = activeDescendantAssociations[ j ]; assert && AccessibilityUtil.validateAssociationObject( associationObject ); } @@ -1822,10 +1822,10 @@ define( require => { // if the list isn't the same, TODO: make order in the list not matter if ( !_.isEqual( activeDescendantAssociations, this._activeDescendantAssociations ) ) { - var beforeOnly = []; // Will hold all nodes that will be removed. - var afterOnly = []; // Will hold all nodes that will be "new" children (added) - var inBoth = []; // Child nodes that "stay". Will be ordered for the "after" case. - var i; + const beforeOnly = []; // Will hold all nodes that will be removed. + const afterOnly = []; // Will hold all nodes that will be "new" children (added) + const inBoth = []; // Child nodes that "stay". Will be ordered for the "after" case. + let i; // get a difference of the desired new list, and the old arrayDifference( activeDescendantAssociations, this._activeDescendantAssociations, afterOnly, beforeOnly, inBoth ); @@ -1841,7 +1841,7 @@ define( require => { // add each association from the new list that hasn't been added yet for ( i = 0; i < afterOnly.length; i++ ) { - var activeDescendantAssociation = activeDescendantAssociations[ i ]; + const activeDescendantAssociation = activeDescendantAssociations[ i ]; this.addActiveDescendantAssociation( activeDescendantAssociation ); } @@ -1891,7 +1891,7 @@ define( require => { assert && assert( _.includes( this._activeDescendantAssociations, associationObject ) ); // remove the - var removedObject = this._activeDescendantAssociations.splice( _.indexOf( this._activeDescendantAssociations, associationObject ), 1 ); + const removedObject = this._activeDescendantAssociations.splice( _.indexOf( this._activeDescendantAssociations, associationObject ), 1 ); // remove the reference from the other node back to this node because we don't need it anymore removedObject[ 0 ].otherNode.removeNodeThatIsActiveDescendantThisNode( this ); @@ -1906,7 +1906,7 @@ define( require => { */ removeNodeThatIsActiveDescendantThisNode: function( node ) { assert && assert( node instanceof scenery.Node ); - var indexOfNode = _.indexOf( this._nodesThatAreActiveDescendantToThisNode, node ); + const indexOfNode = _.indexOf( this._nodesThatAreActiveDescendantToThisNode, node ); assert && assert( indexOfNode >= 0 ); this._nodesThatAreActiveDescendantToThisNode.splice( indexOfNode, 1 ); @@ -1917,8 +1917,8 @@ define( require => { * @public */ updateActiveDescendantAssociationsInPeers: function() { - for ( var i = 0; i < this.accessibleInstances.length; i++ ) { - var peer = this.accessibleInstances[ i ].peer; + for ( let i = 0; i < this.accessibleInstances.length; i++ ) { + const peer = this.accessibleInstances[ i ].peer; peer.onActiveDescendantAssociationChange(); } }, @@ -1932,8 +1932,8 @@ define( require => { // if any other nodes are aria-activeDescendant this Node, update those associations too. Since this node's // accessible content needs to be recreated, they need to update their aria-activeDescendant associations accordingly. // TODO: only use unique elements of the array (_.unique) - for ( var i = 0; i < this._nodesThatAreActiveDescendantToThisNode.length; i++ ) { - var otherNode = this._nodesThatAreActiveDescendantToThisNode[ i ]; + for ( let i = 0; i < this._nodesThatAreActiveDescendantToThisNode.length; i++ ) { + const otherNode = this._nodesThatAreActiveDescendantToThisNode[ i ]; otherNode.updateActiveDescendantAssociationsInPeers(); } }, @@ -2017,7 +2017,7 @@ define( require => { // Only update if it has changed if ( this._accessibleOrder !== accessibleOrder ) { - var oldAccessibleOrder = this._accessibleOrder; + const oldAccessibleOrder = this._accessibleOrder; // Store our own reference to this, so client modifications to the input array won't silently break things. // See https://github.com/phetsims/scenery/issues/786 @@ -2087,9 +2087,9 @@ define( require => { */ getEffectiveChildren: function() { // Find all children without accessible parents. - var nonOrderedChildren = []; - for ( var i = 0; i < this._children.length; i++ ) { - var child = this._children[ i ]; + const nonOrderedChildren = []; + for ( let i = 0; i < this._children.length; i++ ) { + const child = this._children[ i ]; if ( !child._accessibleParent ) { nonOrderedChildren.push( child ); @@ -2098,9 +2098,9 @@ define( require => { // Override the order, and replace the placeholder if it exists. if ( this.hasAccessibleOrder() ) { - var effectiveChildren = this.accessibleOrder.slice(); + const effectiveChildren = this.accessibleOrder.slice(); - var placeholderIndex = effectiveChildren.indexOf( null ); + const placeholderIndex = effectiveChildren.indexOf( null ); // If we have a placeholder, replace its content with the children if ( placeholderIndex >= 0 ) { @@ -2169,8 +2169,8 @@ define( require => { if ( value !== this._inputValue ) { this._inputValue = value; - for ( var i = 0; i < this.accessibleInstances.length; i++ ) { - var peer = this.accessibleInstances[ i ].peer; + for ( let i = 0; i < this.accessibleInstances.length; i++ ) { + const peer = this.accessibleInstances[ i ].peer; peer.onInputValueChange(); } } @@ -2273,8 +2273,8 @@ define( require => { // if the accessible attribute already exists in the list, remove it - no need // to remove from the peers, existing attributes will simply be replaced in the DOM - for ( var i = 0; i < this._accessibleAttributes.length; i++ ) { - var currentAttribute = this._accessibleAttributes[ i ]; + for ( let i = 0; i < this._accessibleAttributes.length; i++ ) { + const currentAttribute = this._accessibleAttributes[ i ]; if ( currentAttribute.attribute === attribute && currentAttribute.options.namespace === options.namespace && currentAttribute.options.asProperty === options.asProperty && @@ -2289,8 +2289,8 @@ define( require => { options: options } ); - for ( var j = 0; j < this._accessibleInstances.length; j++ ) { - var peer = this._accessibleInstances[ j ].peer; + for ( let j = 0; j < this._accessibleInstances.length; j++ ) { + const peer = this._accessibleInstances[ j ].peer; peer.setAttributeToElement( attribute, value, options ); } }, @@ -2316,8 +2316,8 @@ define( require => { elementName: AccessiblePeer.PRIMARY_SIBLING // see AccessiblePeer.getElementName() for valid values, default to the primary sibling }, options ); - var attributeRemoved = false; - for ( var i = 0; i < this._accessibleAttributes.length; i++ ) { + let attributeRemoved = false; + for ( let i = 0; i < this._accessibleAttributes.length; i++ ) { if ( this._accessibleAttributes[ i ].attribute === attribute && this._accessibleAttributes[ i ].options.namespace === options.namespace && this._accessibleAttributes[ i ].options.elementName === options.elementName ) { @@ -2327,8 +2327,8 @@ define( require => { } assert && assert( attributeRemoved, 'Node does not have accessible attribute ' + attribute ); - for ( var j = 0; j < this._accessibleInstances.length; j++ ) { - var peer = this._accessibleInstances[ j ].peer; + for ( let j = 0; j < this._accessibleInstances.length; j++ ) { + const peer = this._accessibleInstances[ j ].peer; peer.removeAttributeFromElement( attribute, options ); } }, @@ -2340,10 +2340,10 @@ define( require => { removeAccessibleAttributes: function() { // all attributes currently on this Node's primary sibling - var attributes = this.getAccessibleAttributes(); + const attributes = this.getAccessibleAttributes(); - for ( var i = 0; i < attributes.length; i++ ) { - var attribute = attributes[ i ].attribute; + for ( let i = 0; i < attributes.length; i++ ) { + const attribute = attributes[ i ].attribute; this.removeAccessibleAttribute( attribute ); } }, @@ -2370,8 +2370,8 @@ define( require => { elementName: AccessiblePeer.PRIMARY_SIBLING // see AccessiblePeer.getElementName() for valid values, default to the primary sibling }, options ); - var attributeFound = false; - for ( var i = 0; i < this._accessibleAttributes.length; i++ ) { + let attributeFound = false; + for ( let i = 0; i < this._accessibleAttributes.length; i++ ) { if ( this._accessibleAttributes[ i ].attribute === attribute && this._accessibleAttributes[ i ].options.namespace === options.namespace && this._accessibleAttributes[ i ].options.elementName === options.elementName ) { @@ -2397,7 +2397,7 @@ define( require => { if ( this._focusableOverride !== focusable ) { this._focusableOverride = focusable; - for ( var i = 0; i < this._accessibleInstances.length; i++ ) { + for ( let i = 0; i < this._accessibleInstances.length; i++ ) { // after the override is set, update the focusability of the peer based on this node's value for focusable // which may be true or false (but not null) @@ -2442,10 +2442,10 @@ define( require => { */ getBaseOptions: function() { - var currentOptions = {}; + const currentOptions = {}; - for ( var i = 0; i < ACCESSIBILITY_OPTION_KEYS.length; i++ ) { - var optionName = ACCESSIBILITY_OPTION_KEYS[ i ]; + for ( let i = 0; i < ACCESSIBILITY_OPTION_KEYS.length; i++ ) { + const optionName = ACCESSIBILITY_OPTION_KEYS[ i ]; currentOptions[ optionName ] = this[ optionName ]; } @@ -2461,22 +2461,22 @@ define( require => { * @returns {Array.} */ getNestedAccessibleOrder: function() { - var currentTrail = new scenery.Trail( this ); - var pruneStack = []; // {Array.} - A list of nodes to prune + const currentTrail = new scenery.Trail( this ); + let pruneStack = []; // {Array.} - A list of nodes to prune // {Array.} - The main result we will be returning. It is the top-level array where child items will be // inserted. - var result = []; + const result = []; // {Array.>} A stack of children arrays, where we should be inserting items into the top array. // We will start out with the result, and as nested levels are added, the children arrays of those items will be // pushed and poppped, so that the top array on this stack is where we should insert our next child item. - var nestedChildStack = [ result ]; + const nestedChildStack = [ result ]; function addTrailsForNode( node, overridePruning ) { // If subtrees were specified with accessibleOrder, they should be skipped from the ordering of ancestor subtrees, // otherwise we could end up having multiple references to the same trail (which should be disallowed). - var pruneCount = 0; + let pruneCount = 0; // count the number of times our node appears in the pruneStack _.each( pruneStack, function( pruneNode ) { if ( node === pruneNode ) { @@ -2493,7 +2493,7 @@ define( require => { // Pushing item and its children array, if accessible if ( node.accessibleContent ) { - var item = { + const item = { trail: currentTrail.copy(), children: [] }; @@ -2501,7 +2501,7 @@ define( require => { nestedChildStack.push( item.children ); } - var arrayAccessibleOrder = node._accessibleOrder === null ? [] : node._accessibleOrder; + const arrayAccessibleOrder = node._accessibleOrder === null ? [] : node._accessibleOrder; // push specific focused nodes to the stack pruneStack = pruneStack.concat( arrayAccessibleOrder ); @@ -2522,9 +2522,9 @@ define( require => { } ); // Visit everything. If there is an accessibleOrder, those trails were already visited, and will be excluded. - var numChildren = node._children.length; - for ( var i = 0; i < numChildren; i++ ) { - var child = node._children[ i ]; + const numChildren = node._children.length; + for ( let i = 0; i < numChildren; i++ ) { + const child = node._children[ i ]; currentTrail.addDescendant( child, i ); addTrailsForNode( child, false ); @@ -2675,7 +2675,7 @@ define( require => { */ removeAccessibleInstance: function( accessibleInstance ) { assert && assert( accessibleInstance instanceof scenery.AccessibleInstance ); - var index = _.indexOf( this._accessibleInstances, accessibleInstance ); + const index = _.indexOf( this._accessibleInstances, accessibleInstance ); assert && assert( index !== -1, 'Cannot remove an AccessibleInstance from a Node if it was not there' ); this._accessibleInstances.splice( index, 1 ); } diff --git a/js/accessibility/AccessibilityFuzzer.js b/js/accessibility/AccessibilityFuzzer.js index eab634c64..e726c71c2 100644 --- a/js/accessibility/AccessibilityFuzzer.js +++ b/js/accessibility/AccessibilityFuzzer.js @@ -60,15 +60,15 @@ define( require => { * @public */ step: function() { - var action = this.random.sample( this.enumerateActions() ); + const action = this.random.sample( this.enumerateActions() ); this.logToConsole && console.log( action.text ); this.actionsTaken.push( action ); action.execute(); this.display._rootAccessibleInstance.auditRoot(); AccessibilityTree.auditAccessibleDisplays( this.display.rootNode ); if ( this.logToConsole ) { - for ( var i = 0; i < this.nodes.length; i++ ) { - var node = this.nodes[ i ]; + for ( let i = 0; i < this.nodes.length; i++ ) { + const node = this.nodes[ i ]; console.log( i + '#' + node.id + ' ' + node.tagName + ' ch:' + AccessibilityTree.debugOrder( node.children ) + ' or:' + AccessibilityTree.debugOrder( node.accessibleOrder ) + ' vis:' + node.visible + ' avis:' + node.accessibleVisible ); } } @@ -81,8 +81,8 @@ define( require => { * @returns {Array.} - like { text: {string}, execute: {function} } */ enumerateActions: function() { - var self = this; - var actions = []; + const self = this; + const actions = []; this.nodes.forEach( function( a ) { actions.push( { @@ -171,7 +171,7 @@ define( require => { return [ [] ]; } else { - var lists = this.powerSet( list.slice( 1 ) ); + const lists = this.powerSet( list.slice( 1 ) ); return lists.concat( lists.map( function( subList ) { return [ list[ 0 ] ].concat( subList ); } ) ); @@ -186,7 +186,7 @@ define( require => { * @param {Array.|null} order */ isAccessibleOrderChangeLegal: function( node, order ) { - var self = this; + const self = this; // remap for equivalence, so it's an array of nodes if ( order === null ) { order = []; } @@ -198,13 +198,13 @@ define( require => { } // Can't include nodes that are included in other accessible orders - for ( var i = 0; i < order.length; i++ ) { + for ( let i = 0; i < order.length; i++ ) { if ( order[ i ]._accessibleParent && order[ i ]._accessibleParent !== node ) { return false; } } - var hasConnection = function( a, b ) { + const hasConnection = function( a, b ) { if ( a === node ) { return a.hasChild( b ) || _.includes( order, b ); } @@ -213,7 +213,7 @@ define( require => { } }; - var effectiveChildren = node.children.concat( order ); + const effectiveChildren = node.children.concat( order ); return _.every( effectiveChildren, function( child ) { return self.isAcyclic( node, child, hasConnection ); } ); @@ -233,7 +233,7 @@ define( require => { return false; } - var nodes = child.children.concat( child.accessibleOrder ).filter( function( n ) { + const nodes = child.children.concat( child.accessibleOrder ).filter( function( n ) { return n !== null; } ); // super defensive diff --git a/js/accessibility/AccessibilityTests.js b/js/accessibility/AccessibilityTests.js index 01665b2a6..462c0db2c 100644 --- a/js/accessibility/AccessibilityTests.js +++ b/js/accessibility/AccessibilityTests.js @@ -18,27 +18,27 @@ define( require => { const Rectangle = require( 'SCENERY/nodes/Rectangle' ); // constants - var TEST_INNER_CONTENT = 'Test Inner Content Here please^&*. Thanks you so very mucho.'; - var TEST_LABEL = 'Test label'; - var TEST_LABEL_2 = 'Test label 2'; - var TEST_DESCRIPTION = 'Test description'; - var TEST_LABEL_HTML = 'I ROCK as a LABEL'; - var TEST_LABEL_HTML_2 = 'I ROCK as a LABEL 2'; - var TEST_DESCRIPTION_HTML = 'I ROCK as a DESCRIPTION'; - var TEST_DESCRIPTION_HTML_2 = 'I ROCK as a DESCRIPTION 2'; + const TEST_INNER_CONTENT = 'Test Inner Content Here please^&*. Thanks you so very mucho.'; + const TEST_LABEL = 'Test label'; + const TEST_LABEL_2 = 'Test label 2'; + const TEST_DESCRIPTION = 'Test description'; + const TEST_LABEL_HTML = 'I ROCK as a LABEL'; + const TEST_LABEL_HTML_2 = 'I ROCK as a LABEL 2'; + const TEST_DESCRIPTION_HTML = 'I ROCK as a DESCRIPTION'; + const TEST_DESCRIPTION_HTML_2 = 'I ROCK as a DESCRIPTION 2'; // These should manually match the defaults in the Accessibility.js trait - var DEFAULT_LABEL_TAG_NAME = AccessibilityUtil.DEFAULT_LABEL_TAG_NAME; - var DEFAULT_DESCRIPTION_TAG_NAME = AccessibilityUtil.DEFAULT_DESCRIPTION_TAG_NAME; + const DEFAULT_LABEL_TAG_NAME = AccessibilityUtil.DEFAULT_LABEL_TAG_NAME; + const DEFAULT_DESCRIPTION_TAG_NAME = AccessibilityUtil.DEFAULT_DESCRIPTION_TAG_NAME; // given the parent container element for a node, this value is the index of the label sibling in the // parent's array of children HTMLElements. - var DEFAULT_LABEL_SIBLING_INDEX = 0; - var DEFAULT_DESCRIPTION_SIBLING_INDEX = 1; - var APPENDED_DESCRIPTION_SIBLING_INDEX = 2; + const DEFAULT_LABEL_SIBLING_INDEX = 0; + const DEFAULT_DESCRIPTION_SIBLING_INDEX = 1; + const APPENDED_DESCRIPTION_SIBLING_INDEX = 2; // a focus highlight for testing, since dummy nodes tend to have no bounds - var TEST_HIGHLIGHT = new Circle( 5 ); + const TEST_HIGHLIGHT = new Circle( 5 ); QUnit.module( 'Accessibility' ); @@ -76,7 +76,7 @@ define( require => { */ function getPrimarySiblingElementByNode( node ) { - var uniquePeer = getAccessiblePeerByNode( node ); + const uniquePeer = getAccessiblePeerByNode( node ); return document.getElementById( uniquePeer.primarySibling.id ); } @@ -84,16 +84,16 @@ define( require => { QUnit.test( 'tagName/innerContent options', function( assert ) { // test the behavior of swapVisibility function - var rootNode = new Node( { tagName: 'div' } ); + const rootNode = new Node( { tagName: 'div' } ); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // create some nodes for testing - var a = new Node( { tagName: 'button', innerContent: TEST_LABEL } ); + const a = new Node( { tagName: 'button', innerContent: TEST_LABEL } ); rootNode.addChild( a ); - var aElement = getPrimarySiblingElementByNode( a ); + const aElement = getPrimarySiblingElementByNode( a ); assert.ok( a.accessibleInstances.length === 1, 'only 1 instance' ); assert.ok( aElement.parentElement.childNodes.length === 1, 'parent contains one primary siblings' ); assert.ok( aElement.tagName === 'BUTTON', 'default label tagName' ); @@ -116,7 +116,7 @@ define( require => { assert.ok( getPrimarySiblingElementByNode( a ).innerHTML === TEST_LABEL_HTML_2, 'innerContent not cleared when tagName set to null.' ); // verify that setting inner content on an input is not allowed - var b = new Node( { tagName: 'input' } ); + const b = new Node( { tagName: 'input' } ); rootNode.addChild( b ); window.assert && assert.throws( function() { b.innerContent = 'this should fail'; @@ -139,12 +139,12 @@ define( require => { // test the behavior of swapVisibility function - var rootNode = new Node( { tagName: 'div' } ); + const rootNode = new Node( { tagName: 'div' } ); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // create some nodes for testing - var a = new Node( { tagName: 'button' } ); + const a = new Node( { tagName: 'button' } ); rootNode.addChild( a ); assert.ok( a.accessibleInstances.length === 1, 'only 1 instance' ); @@ -167,17 +167,17 @@ define( require => { QUnit.test( 'labelTagName/labelContent option', function( assert ) { // test the behavior of swapVisibility function - var rootNode = new Node( { tagName: 'div' } ); + const rootNode = new Node( { tagName: 'div' } ); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // create some nodes for testing - var a = new Node( { tagName: 'button', labelContent: TEST_LABEL } ); + const a = new Node( { tagName: 'button', labelContent: TEST_LABEL } ); rootNode.addChild( a ); - var aElement = getPrimarySiblingElementByNode( a ); - var labelSibling = aElement.parentElement.childNodes[ 0 ]; + const aElement = getPrimarySiblingElementByNode( a ); + const labelSibling = aElement.parentElement.childNodes[ 0 ]; assert.ok( a.accessibleInstances.length === 1, 'only 1 instance' ); assert.ok( aElement.parentElement.childNodes.length === 2, 'parent contains two siblings' ); assert.ok( labelSibling.tagName === DEFAULT_LABEL_TAG_NAME, 'default label tagName' ); @@ -191,8 +191,8 @@ define( require => { a.tagName = 'div'; - var newAElement = getPrimarySiblingElementByNode( a ); - var newLabelSibling = newAElement.parentElement.childNodes[ 0 ]; + const newAElement = getPrimarySiblingElementByNode( a ); + const newLabelSibling = newAElement.parentElement.childNodes[ 0 ]; assert.ok( newLabelSibling.innerHTML === TEST_LABEL_HTML_2, 'tagName independent of: html label should use innerHTML, overwrite from html' ); @@ -207,39 +207,39 @@ define( require => { a.labelTagName = 'p'; assert.ok( a.labelTagName === 'p', 'expect labelTagName setter to work.' ); - var b = new Node( { tagName: 'p', labelContent: 'I am groot' } ); + const b = new Node( { tagName: 'p', labelContent: 'I am groot' } ); rootNode.addChild( b ); - var bLabelElement = document.getElementById( b.accessibleInstances[ 0 ].peer.labelSibling.id ); + let bLabelElement = document.getElementById( b.accessibleInstances[ 0 ].peer.labelSibling.id ); assert.ok( !bLabelElement.getAttribute( 'for' ), 'for attribute should not be on non label label sibling.' ); b.labelTagName = 'label'; bLabelElement = document.getElementById( b.accessibleInstances[ 0 ].peer.labelSibling.id ); assert.ok( bLabelElement.getAttribute( 'for' ) !== null, 'for attribute should be on "label" tag for label sibling.' ); - var c = new Node( { tagName: 'p' } ); + const c = new Node( { tagName: 'p' } ); rootNode.addChild( c ); c.labelTagName = 'label'; c.labelContent = TEST_LABEL; - var cLabelElement = document.getElementById( c.accessibleInstances[ 0 ].peer.labelSibling.id ); + const cLabelElement = document.getElementById( c.accessibleInstances[ 0 ].peer.labelSibling.id ); assert.ok( cLabelElement.getAttribute( 'for' ) !== null, 'order should not matter' ); } ); QUnit.test( 'container element not needed for multiple siblings', function( assert ) { // test the behavior of swapVisibility function - var rootNode = new Node( { tagName: 'div' } ); + const rootNode = new Node( { tagName: 'div' } ); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // test containerTag is not needed - var b = new Node( { + const b = new Node( { tagName: 'div', labelContent: 'hello' } ); - var c = new Node( { + const c = new Node( { tagName: 'section', labelContent: 'hi' } ); - var d = new Node( { + const d = new Node( { tagName: 'p', innerContent: 'PPPP', containerTagName: 'div' @@ -247,11 +247,11 @@ define( require => { rootNode.addChild( b ); b.addChild( c ); b.addChild( d ); - var bElement = getPrimarySiblingElementByNode( b ); - var cPeer = c.accessibleInstances[ 0 ].peer; - var dPeer = d.accessibleInstances[ 0 ].peer; + let bElement = getPrimarySiblingElementByNode( b ); + let cPeer = c.accessibleInstances[ 0 ].peer; + let dPeer = d.accessibleInstances[ 0 ].peer; assert.ok( bElement.children.length === 3, 'c.p, c.section, d.div should all be on the same level' ); - var confirmOriginalOrder = function() { + const confirmOriginalOrder = function() { assert.ok( bElement.children[ 0 ].tagName === 'P', 'p first' ); assert.ok( bElement.children[ 1 ].tagName === 'SECTION', 'section 2nd' ); assert.ok( bElement.children[ 2 ].tagName === 'DIV', 'div 3rd' ); @@ -262,7 +262,7 @@ define( require => { confirmOriginalOrder(); // add a few more - var e = new Node( { + const e = new Node( { tagName: 'span', descriptionContent: '
sweet and cool things
' } ); @@ -270,11 +270,11 @@ define( require => { bElement = getPrimarySiblingElementByNode( b ); // refresh the DOM Elements cPeer = c.accessibleInstances[ 0 ].peer; // refresh the DOM Elements dPeer = d.accessibleInstances[ 0 ].peer; // refresh the DOM Elements - var ePeer = e.accessibleInstances[ 0 ].peer; + let ePeer = e.accessibleInstances[ 0 ].peer; assert.ok( bElement.children.length === 5, 'e children should be added to the same PDOM level.' ); confirmOriginalOrder(); - var confirmOriginalWithE = function() { + const confirmOriginalWithE = function() { assert.ok( bElement.children[ 3 ].tagName === 'P', 'P 4rd' ); assert.ok( bElement.children[ 4 ].tagName === 'SPAN', 'SPAN 3rd' ); assert.ok( bElement.children[ 3 ] === ePeer.descriptionSibling, 'e description 4th' ); @@ -321,17 +321,17 @@ define( require => { QUnit.test( 'descriptionTagName/descriptionContent option', function( assert ) { // test the behavior of swapVisibility function - var rootNode = new Node( { tagName: 'div' } ); + const rootNode = new Node( { tagName: 'div' } ); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // create some nodes for testing - var a = new Node( { tagName: 'button', descriptionContent: TEST_DESCRIPTION } ); + const a = new Node( { tagName: 'button', descriptionContent: TEST_DESCRIPTION } ); rootNode.addChild( a ); - var aElement = getPrimarySiblingElementByNode( a ); - var descriptionSibling = aElement.parentElement.childNodes[ 0 ]; + const aElement = getPrimarySiblingElementByNode( a ); + const descriptionSibling = aElement.parentElement.childNodes[ 0 ]; assert.ok( a.accessibleInstances.length === 1, 'only 1 instance' ); assert.ok( aElement.parentElement.childNodes.length === 2, 'parent contains two siblings' ); assert.ok( descriptionSibling.tagName === DEFAULT_DESCRIPTION_TAG_NAME, 'default label tagName' ); @@ -359,12 +359,12 @@ define( require => { QUnit.test( 'Accessibility options', function( assert ) { - var rootNode = new Node(); + const rootNode = new Node(); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // test setting of accessible content through options - var buttonNode = new Node( { + const buttonNode = new Node( { focusHighlight: new Circle( 5 ), containerTagName: 'div', // contained in parent element 'div' tagName: 'input', // dom element with tag name 'input' @@ -377,7 +377,7 @@ define( require => { } ); rootNode.addChild( buttonNode ); - var divNode = new Node( { + const divNode = new Node( { tagName: 'div', ariaLabel: TEST_LABEL, // use ARIA label attribute accessibleVisible: false, // hidden from screen readers (and browser) @@ -417,14 +417,14 @@ define( require => { //

Test Description

// // - var buttonElement = getPrimarySiblingElementByNode( buttonNode ); + let buttonElement = getPrimarySiblingElementByNode( buttonNode ); - var buttonParent = buttonElement.parentNode; - var buttonPeers = buttonParent.childNodes; - var buttonLabel = buttonPeers[ 0 ]; - var buttonDescription = buttonPeers[ 1 ]; - var divElement = getPrimarySiblingElementByNode( divNode ); - var pDescription = divElement.parentElement.childNodes[ 0 ]; // description before primary div + const buttonParent = buttonElement.parentNode; + const buttonPeers = buttonParent.childNodes; + const buttonLabel = buttonPeers[ 0 ]; + const buttonDescription = buttonPeers[ 1 ]; + const divElement = getPrimarySiblingElementByNode( divNode ); + const pDescription = divElement.parentElement.childNodes[ 0 ]; // description before primary div assert.ok( buttonParent.tagName === 'DIV', 'parent container' ); assert.ok( buttonLabel.tagName === 'LABEL', 'Label first' ); @@ -453,7 +453,7 @@ define( require => { function testAssociationAttribute( assert, attribute ) { // eslint-disable-line // use a different setter depending on if testing labelledby or describedby - var addAssociationFunction = attribute === 'aria-labelledby' ? 'addAriaLabelledbyAssociation' : + const addAssociationFunction = attribute === 'aria-labelledby' ? 'addAriaLabelledbyAssociation' : attribute === 'aria-describedby' ? 'addAriaDescribedbyAssociation' : attribute === 'aria-activedescendant' ? 'addActiveDescendantAssociation' : null; @@ -463,13 +463,13 @@ define( require => { } - var rootNode = new Node(); + const rootNode = new Node(); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // two new nodes that will be related with the aria-labelledby and aria-describedby associations - var a = new Node( { tagName: 'button', labelTagName: 'p', descriptionTagName: 'p' } ); - var b = new Node( { tagName: 'p', innerContent: TEST_LABEL_2 } ); + const a = new Node( { tagName: 'button', labelTagName: 'p', descriptionTagName: 'p' } ); + const b = new Node( { tagName: 'p', innerContent: TEST_LABEL_2 } ); rootNode.children = [ a, b ]; @@ -484,11 +484,11 @@ define( require => { otherElementName: AccessiblePeer.PRIMARY_SIBLING } ); - var aElement = getPrimarySiblingElementByNode( a ); - var bElement = getPrimarySiblingElementByNode( b ); + let aElement = getPrimarySiblingElementByNode( a ); + let bElement = getPrimarySiblingElementByNode( b ); assert.ok( aElement.getAttribute( attribute ).indexOf( bElement.id ) >= 0, attribute + ' for one node.' ); - var c = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); + const c = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); rootNode.addChild( c ); a[ addAssociationFunction ]( { @@ -499,15 +499,15 @@ define( require => { aElement = getPrimarySiblingElementByNode( a ); bElement = getPrimarySiblingElementByNode( b ); - var cElement = getPrimarySiblingElementByNode( c ); - var expectedValue = [ bElement.id, cElement.id ].join( ' ' ); + let cElement = getPrimarySiblingElementByNode( c ); + const expectedValue = [ bElement.id, cElement.id ].join( ' ' ); assert.ok( aElement.getAttribute( attribute ) === expectedValue, attribute + ' two nodes' ); // Make c invalidate rootNode.removeChild( c ); rootNode.addChild( new Node( { children: [ c ] } ) ); - var oldValue = expectedValue; + const oldValue = expectedValue; aElement = getPrimarySiblingElementByNode( a ); cElement = getPrimarySiblingElementByNode( c ); @@ -516,7 +516,7 @@ define( require => { assert.ok( aElement.getAttribute( attribute ) === [ bElement.id, cElement.id ].join( ' ' ), 'should have invalidated on tree change' ); - var d = new Node( { tagName: 'div', descriptionTagName: 'p', innerContent: TEST_LABEL, containerTagName: 'div' } ); + const d = new Node( { tagName: 'div', descriptionTagName: 'p', innerContent: TEST_LABEL, containerTagName: 'div' } ); rootNode.addChild( d ); b[ addAssociationFunction ]( { @@ -526,8 +526,8 @@ define( require => { } ); b.containerTagName = 'div'; - var bParentContainer = getPrimarySiblingElementByNode( b ).parentElement; - var dDescriptionElement = getPrimarySiblingElementByNode( d ).parentElement.childNodes[ 0 ]; + const bParentContainer = getPrimarySiblingElementByNode( b ).parentElement; + const dDescriptionElement = getPrimarySiblingElementByNode( d ).parentElement.childNodes[ 0 ]; assert.ok( bParentContainer.getAttribute( attribute ) !== oldValue, 'should have invalidated on tree change' ); assert.ok( bParentContainer.getAttribute( attribute ) === dDescriptionElement.id, 'b parent container element is ' + attribute + ' d description sibling' ); @@ -542,10 +542,10 @@ define( require => { // \ // h // we want to make sure - var e = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); - var f = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); - var g = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); - var h = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); + const e = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); + const f = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); + const g = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); + const h = new Node( { tagName: 'div', innerContent: TEST_LABEL } ); e.addChild( f ); f.addChild( g ); g.addChild( h ); @@ -569,10 +569,10 @@ define( require => { otherElementName: AccessiblePeer.PRIMARY_SIBLING } ); - var eElement = getPrimarySiblingElementByNode( e ); - var fElement = getPrimarySiblingElementByNode( f ); - var gElement = getPrimarySiblingElementByNode( g ); - var hElement = getPrimarySiblingElementByNode( h ); + let eElement = getPrimarySiblingElementByNode( e ); + let fElement = getPrimarySiblingElementByNode( f ); + let gElement = getPrimarySiblingElementByNode( g ); + let hElement = getPrimarySiblingElementByNode( h ); assert.ok( eElement.getAttribute( attribute ) === fElement.id, 'eElement should be ' + attribute + ' fElement' ); assert.ok( fElement.getAttribute( attribute ) === gElement.id, 'fElement should be ' + attribute + ' gElement' ); assert.ok( gElement.getAttribute( attribute ) === hElement.id, 'gElement should be ' + attribute + ' hElement' ); @@ -601,8 +601,8 @@ define( require => { assert.ok( gElement.getAttribute( attribute ) === hElement.id, 'gElement should still be ' + attribute + ' hElement' ); // test aria labelled by your self, but a different peer Element, multiple attribute ids included in the test. - var containerTagName = 'div'; - var j = new Node( { + const containerTagName = 'div'; + const j = new Node( { tagName: 'button', labelTagName: 'label', descriptionTagName: 'p', @@ -628,13 +628,13 @@ define( require => { otherElementName: AccessiblePeer.LABEL_SIBLING } ); - var checkOnYourOwnAssociations = function( node ) { + const checkOnYourOwnAssociations = function( node ) { - var instance = node._accessibleInstances[ 0 ]; - var nodePrimaryElement = instance.peer.primarySibling; - var nodeParent = nodePrimaryElement.parentElement; - var nodeLabelElement = nodeParent.childNodes[ DEFAULT_LABEL_SIBLING_INDEX ]; - var nodeDescriptionElement = nodeParent.childNodes[ DEFAULT_DESCRIPTION_SIBLING_INDEX ]; + const instance = node._accessibleInstances[ 0 ]; + const nodePrimaryElement = instance.peer.primarySibling; + const nodeParent = nodePrimaryElement.parentElement; + const nodeLabelElement = nodeParent.childNodes[ DEFAULT_LABEL_SIBLING_INDEX ]; + const nodeDescriptionElement = nodeParent.childNodes[ DEFAULT_DESCRIPTION_SIBLING_INDEX ]; assert.ok( nodePrimaryElement.getAttribute( attribute ).indexOf( nodeLabelElement.id ) >= 0, attribute + ' your own label element.' ); assert.ok( nodeParent.getAttribute( attribute ).indexOf( nodeDescriptionElement.id ) >= 0, 'parent ' + attribute + ' your own description.' ); @@ -644,16 +644,16 @@ define( require => { }; // add k into the mix - var k = new Node( { tagName: 'div' } ); + const k = new Node( { tagName: 'div' } ); k[ addAssociationFunction ]( { otherNode: j, thisElementName: AccessiblePeer.PRIMARY_SIBLING, otherElementName: AccessiblePeer.LABEL_SIBLING } ); rootNode.addChild( k ); - var testK = function() { - var kValue = k._accessibleInstances[ 0 ].peer.primarySibling.getAttribute( attribute ); - var jID = j._accessibleInstances[ 0 ].peer.labelSibling.getAttribute( 'id' ); + const testK = function() { + const kValue = k._accessibleInstances[ 0 ].peer.primarySibling.getAttribute( attribute ); + const jID = j._accessibleInstances[ 0 ].peer.labelSibling.getAttribute( 'id' ); assert.ok( jID === kValue, 'k pointing to j' ); }; @@ -673,7 +673,7 @@ define( require => { testK(); // check dispose - var jParent = new Node( { children: [ j ] } ); + const jParent = new Node( { children: [ j ] } ); rootNode.children = []; rootNode.addChild( jParent ); checkOnYourOwnAssociations( j ); @@ -687,7 +687,7 @@ define( require => { testK(); // check removeChild with dag - var jParent2 = new Node( { children: [ j ] } ); + const jParent2 = new Node( { children: [ j ] } ); rootNode.insertChild( 0, jParent2 ); checkOnYourOwnAssociations( j ); testK(); @@ -699,31 +699,31 @@ define( require => { function testAssociationAttributeBySetters( assert, attribute ) { // eslint-disable-line - var rootNode = new Node(); + const rootNode = new Node(); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // use a different setter depending on if testing labelledby or describedby - var associationsArrayName = attribute === 'aria-labelledby' ? 'ariaLabelledbyAssociations' : + const associationsArrayName = attribute === 'aria-labelledby' ? 'ariaLabelledbyAssociations' : attribute === 'aria-describedby' ? 'ariaDescribedbyAssociations' : attribute === 'aria-activedescendant' ? 'activeDescendantAssociations' : null; // use a different setter depending on if testing labelledby or describedby - var associationRemovalFunction = attribute === 'aria-labelledby' ? 'removeAriaLabelledbyAssociation' : + const associationRemovalFunction = attribute === 'aria-labelledby' ? 'removeAriaLabelledbyAssociation' : attribute === 'aria-describedby' ? 'removeAriaDescribedbyAssociation' : attribute === 'aria-activedescendant' ? 'removeActiveDescendantAssociation' : null; - var options = { + const options = { tagName: 'p', labelContent: 'hi', descriptionContent: 'hello', containerTagName: 'div' }; - var n = new Node( options ); + const n = new Node( options ); rootNode.addChild( n ); options[ associationsArrayName ] = [ { @@ -732,16 +732,16 @@ define( require => { otherElementName: AccessiblePeer.LABEL_SIBLING } ]; - var o = new Node( options ); + const o = new Node( options ); rootNode.addChild( o ); - var nElement = getPrimarySiblingElementByNode( n ); - var oElement = getPrimarySiblingElementByNode( o ); + const nElement = getPrimarySiblingElementByNode( n ); + const oElement = getPrimarySiblingElementByNode( o ); assert.ok( oElement.getAttribute( attribute ).indexOf( nElement.id ) >= 0, attribute + ' for two nodes with setter.' ); // make a list of associations to test as a setter - var randomAssociationObject = { + const randomAssociationObject = { otherNode: new Node(), thisElementName: AccessiblePeer.CONTAINER_PARENT, otherElementName: AccessiblePeer.LABEL_SIBLING @@ -761,7 +761,7 @@ define( require => { ]; // test getters and setters - var m = new Node( options ); + const m = new Node( options ); rootNode.addChild( m ); assert.ok( _.isEqual( m[ associationsArrayName ], options[ associationsArrayName ] ), 'test association object getter' ); m[ associationRemovalFunction ]( randomAssociationObject ); @@ -799,8 +799,8 @@ define( require => { QUnit.test( 'Accessibility invalidation', function( assert ) { // test invalidation of accessibility (changing content which requires ) - var a1 = new Node(); - var rootNode = new Node(); + const a1 = new Node(); + const rootNode = new Node(); a1.tagName = 'button'; @@ -811,7 +811,7 @@ define( require => { rootNode.addChild( a1 ); // verify that elements are in the DOM - var a1Element = getPrimarySiblingElementByNode( a1 ); + const a1Element = getPrimarySiblingElementByNode( a1 ); assert.ok( a1Element, 'button in DOM' ); assert.ok( a1Element.tagName === 'BUTTON', 'button tag name set' ); @@ -820,9 +820,9 @@ define( require => { a1.descriptionTagName = 'p'; a1.containerTagName = 'div'; - var buttonElement = a1.accessibleInstances[ 0 ].peer.primarySibling; - var parentElement = buttonElement.parentElement; - var buttonPeers = parentElement.childNodes; + let buttonElement = a1.accessibleInstances[ 0 ].peer.primarySibling; + let parentElement = buttonElement.parentElement; + const buttonPeers = parentElement.childNodes; // now html should look like //
@@ -855,20 +855,20 @@ define( require => { assert.ok( parentElement.childNodes[ 1 ].id.indexOf( 'description' ) >= 0, 'description after div when appending both elements' ); assert.ok( parentElement.childNodes.length === 2, 'no label peer when using just aria-label attribute' ); - var elementInDom = document.getElementById( a1.accessibleInstances[ 0 ].peer.primarySibling.id ); + const elementInDom = document.getElementById( a1.accessibleInstances[ 0 ].peer.primarySibling.id ); assert.ok( elementInDom.getAttribute( 'aria-label' ) === TEST_LABEL, 'aria-label set' ); } ); QUnit.test( 'Accessibility setters/getters', function( assert ) { - var a1 = new Node( { + const a1 = new Node( { tagName: 'div' } ); var display = new Display( a1 ); // eslint-disable-line document.body.appendChild( display.domElement ); // set/get attributes - var a1Element = getPrimarySiblingElementByNode( a1 ); + let a1Element = getPrimarySiblingElementByNode( a1 ); a1.setAccessibleAttribute( 'role', 'switch' ); assert.ok( a1.getAccessibleAttributes()[ 0 ].attribute === 'role', 'attribute set' ); assert.ok( a1Element.getAttribute( 'role' ) === 'switch', 'HTML attribute set' ); @@ -878,7 +878,7 @@ define( require => { assert.ok( !a1.hasAccessibleAttribute( 'role' ), 'should not have accessible attribute' ); assert.ok( !a1Element.getAttribute( 'role' ), 'attribute removed' ); - var b = new Node( { focusable: true } ); + const b = new Node( { focusable: true } ); a1.addChild( b ); b.tagName = 'div'; assert.ok( getPrimarySiblingElementByNode( b ).tabIndex >= 0, 'set tagName after focusable' ); @@ -892,28 +892,28 @@ define( require => { } ); QUnit.test( 'Next/Previous focusable', function( assert ) { - var util = AccessibilityUtil; + const util = AccessibilityUtil; - var rootNode = new Node( { tagName: 'div', focusable: true } ); + const rootNode = new Node( { tagName: 'div', focusable: true } ); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // invisible is deprecated don't use in future, this is a workaround for Nodes without bounds - var a = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); - var b = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); - var c = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); - var d = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); - var e = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const a = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const b = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const c = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const d = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const e = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); rootNode.children = [ a, b, c, d ]; assert.ok( a.focusable, 'should be focusable' ); // get dom elements from the body - var rootElement = getPrimarySiblingElementByNode( rootNode ); - var aElement = getPrimarySiblingElementByNode( a ); - var bElement = getPrimarySiblingElementByNode( b ); - var cElement = getPrimarySiblingElementByNode( c ); - var dElement = getPrimarySiblingElementByNode( d ); + const rootElement = getPrimarySiblingElementByNode( rootNode ); + const aElement = getPrimarySiblingElementByNode( a ); + const bElement = getPrimarySiblingElementByNode( b ); + const cElement = getPrimarySiblingElementByNode( c ); + const dElement = getPrimarySiblingElementByNode( d ); a.focus(); assert.ok( document.activeElement.id === aElement.id, 'a in focus (next)' ); @@ -958,21 +958,21 @@ define( require => { } ); QUnit.test( 'Remove accessibility subtree', function( assert ) { - var rootNode = new Node( { tagName: 'div', focusable: true } ); + const rootNode = new Node( { tagName: 'div', focusable: true } ); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); - var a = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); - var b = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); - var c = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); - var d = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); - var e = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); - var f = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const a = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const b = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const c = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const d = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const e = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); + const f = new Node( { tagName: 'div', focusable: true, focusHighlight: 'invisible' } ); rootNode.children = [ a, b, c, d, e ]; d.addChild( f ); - var rootDOMElement = getPrimarySiblingElementByNode( rootNode ); - var dDOMElement = getPrimarySiblingElementByNode( d ); + let rootDOMElement = getPrimarySiblingElementByNode( rootNode ); + let dDOMElement = getPrimarySiblingElementByNode( d ); // verify the dom assert.ok( rootDOMElement.children.length === 5, 'children added' ); @@ -988,15 +988,15 @@ define( require => { QUnit.test( 'accessible-dag', function( assert ) { // test accessibility for multiple instances of a node - var rootNode = new Node( { tagName: 'div', focusable: true } ); + const rootNode = new Node( { tagName: 'div', focusable: true } ); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); - var a = new Node( { tagName: 'div' } ); - var b = new Node( { tagName: 'div' } ); - var c = new Node( { tagName: 'div' } ); - var d = new Node( { tagName: 'div' } ); - var e = new Node( { tagName: 'div' } ); + const a = new Node( { tagName: 'div' } ); + const b = new Node( { tagName: 'div' } ); + const c = new Node( { tagName: 'div' } ); + const d = new Node( { tagName: 'div' } ); + const e = new Node( { tagName: 'div' } ); rootNode.addChild( a ); a.children = [ b, c, d ]; @@ -1015,7 +1015,7 @@ define( require => { //
//
//
- var instances = e.accessibleInstances; + const instances = e.accessibleInstances; assert.ok( e.accessibleInstances.length === 3, 'node e should have 3 accessible instances' ); assert.ok( ( instances[ 0 ].peer.primarySibling.id !== instances[ 1 ].peer.primarySibling.id ) && ( instances[ 1 ].peer.primarySibling.id !== instances[ 2 ].peer.primarySibling.id ) && @@ -1028,29 +1028,29 @@ define( require => { QUnit.test( 'replaceChild', function( assert ) { // test the behavior of replaceChild function - var rootNode = new Node( { tagName: 'div' } ); + const rootNode = new Node( { tagName: 'div' } ); var display = new Display( rootNode ); // eslint-disable-line document.body.appendChild( display.domElement ); // a custom focus highlight (since dummy node's have no bounds) - var focusHighlight = new Rectangle( 0, 0, 10, 10 ); + const focusHighlight = new Rectangle( 0, 0, 10, 10 ); // create some nodes for testing - var a = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); - var b = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); - var c = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); - var d = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); - var e = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); - var f = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); + const a = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); + const b = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); + const c = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); + const d = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); + const e = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); + const f = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); // a child that will be added through replaceChild() - var testNode = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); + const testNode = new Node( { tagName: 'button', focusHighlight: focusHighlight } ); // make sure replaceChild puts the child in the right spot a.children = [ b, c, d, e, f ]; - var initIndex = a.indexOfChild( e ); + const initIndex = a.indexOfChild( e ); a.replaceChild( e, testNode ); - var afterIndex = a.indexOfChild( testNode ); + const afterIndex = a.indexOfChild( testNode ); assert.ok( a.hasChild( testNode ), 'a should have child testNode after it replaced node e' ); assert.ok( !a.hasChild( e ), 'a should no longer have child node e after it was replaced by testNode' ); @@ -1108,8 +1108,8 @@ define( require => { QUnit.test( 'accessibleVisible', function( assert ) { - var rootNode = new Node(); - var display = new Display( rootNode ); + const rootNode = new Node(); + const display = new Display( rootNode ); document.body.appendChild( display.domElement ); // test with a scene graph @@ -1120,13 +1120,13 @@ define( require => { // d e f // \ / // g - var a = new Node(); - var b = new Node(); - var c = new Node(); - var d = new Node(); - var e = new Node(); - var f = new Node(); - var g = new Node(); + const a = new Node(); + const b = new Node(); + const c = new Node(); + const d = new Node(); + const e = new Node(); + const f = new Node(); + const g = new Node(); rootNode.addChild( a ); a.children = [ b, c ]; @@ -1148,14 +1148,14 @@ define( require => { //