Skip to content

Commit

Permalink
Fixes race condition setting aria roles before Tree rootNode is creat…
Browse files Browse the repository at this point in the history
…ed, plus test updates, thanks Mike (IBM, CCLA), fixes #12135 again, !strict.

git-svn-id: http://svn.dojotoolkit.org/src/dijit/trunk@29284 560b804f-0ae3-0310-86f3-f6aa0a117693
  • Loading branch information
wkeese committed Jul 17, 2012
1 parent 6899242 commit b0d056a
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 28 deletions.
10 changes: 8 additions & 2 deletions Tree.js
Expand Up @@ -789,8 +789,6 @@ var Tree = declare("dijit.Tree", [_Widget, _TemplatedMixin], {
this.connect(this.model, "onChildrenChange", "_onItemChildrenChange");
this.connect(this.model, "onDelete", "_onItemDelete");

this._load();

this.inherited(arguments);

if(this.dndController){
Expand All @@ -806,6 +804,8 @@ var Tree = declare("dijit.Tree", [_Widget, _TemplatedMixin], {
this.dndController = new this.dndController(this, params);
}

this._load();

// If no path was specified to the constructor, use path saved in cookie
if(!this.params.path && !this.params.paths && this.persist){
this.set("paths", this.dndController._getSavedPaths());
Expand All @@ -814,6 +814,7 @@ var Tree = declare("dijit.Tree", [_Widget, _TemplatedMixin], {
// onLoadDeferred should fire when all commands that are part of initialization have completed.
// It will include all the set("paths", ...) commands that happen during initialization.
this.onLoadDeferred = this.pendingCommandsDeferred;

this.onLoadDeferred.then(lang.hitch(this, "onLoad"));
},

Expand Down Expand Up @@ -871,6 +872,7 @@ var Tree = declare("dijit.Tree", [_Widget, _TemplatedMixin], {
textDir: this.textDir,
indent: this.showRoot ? 0 : -1
}));

if(!this.showRoot){
rn.rowNode.style.display="none";
// if root is not visible, move tree role to the invisible
Expand All @@ -882,7 +884,11 @@ var Tree = declare("dijit.Tree", [_Widget, _TemplatedMixin], {
rn.labelNode.setAttribute("role", "presentation");
rn.containerNode.setAttribute("role", "tree");
rn.containerNode.setAttribute("aria-expanded","true");
rn.containerNode.setAttribute("aria-multiselectable", !this.dndController.singular);
}else{
this.domNode.setAttribute("aria-multiselectable", !this.dndController.singular);
}

this.domNode.appendChild(rn.domNode);
var identity = this.model.getIdentity(item);
if(this._itemNodesMap[identity]){
Expand Down
4 changes: 2 additions & 2 deletions tests/tree/CustomLabel.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Dijit Tree Custom Label Test</title>
Expand Down Expand Up @@ -64,7 +64,7 @@

</script>
</head>
<body class="claro">
<body class="claro" role="main">

<h1 class="testTitle">Dijit Tree Custom Label Test</h1>

Expand Down
4 changes: 2 additions & 2 deletions tests/tree/Tree_ForestStoreModel.html
Expand Up @@ -7,7 +7,7 @@
Put new tests in Tree_ObjectStoreModel.html
--->

<html>
<html lang="en">
<head>
<title>dijit.Tree against dijit.tree.ForestStoreModel Automated Tests</title>

Expand Down Expand Up @@ -383,7 +383,7 @@
</script>

</head>
<body class="claro">
<body class="claro" role="main">

<h1 class="testTitle">Dijit.Tree / dijit.tree.ForestStoreModel Automated Tests</h1>
<div id="container"> <!-- tree will go here --></div>
Expand Down
4 changes: 2 additions & 2 deletions tests/tree/Tree_ObjectStoreModel.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>dijit.Tree / dijit.tree.ObjectStoreModel automated test</title>
Expand Down Expand Up @@ -702,7 +702,7 @@
</script>

</head>
<body class="claro">
<body class="claro" role="main">

<h1 class="testTitle">dijit.Tree using dijit.tree.ObjectStore (against dojo.store) Automated Test</h1>

Expand Down
4 changes: 2 additions & 2 deletions tests/tree/Tree_with_JRS.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<html lang="en">
<head>
<title>dijit.Tree Automatic Tests</title>

Expand Down Expand Up @@ -122,7 +122,7 @@
</script>

</head>
<body class="claro">
<body class="claro" role="main">

<h1 class="testTitle">Dijit.Tree automated tests</h1>
<div id="container"> <!-- tree will go here --></div>
Expand Down
4 changes: 2 additions & 2 deletions tests/tree/test_Custom_TreeNode.html
@@ -1,5 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<html lang="en"
<head>
<title>Custom TreeNode Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Expand Down Expand Up @@ -89,7 +89,7 @@
});
</script>
</head>
<body class="claro">
<body class="claro" role="main">
<h1 class="title">Please expand Continent node</h1>
<div id="AAA" style="overflow: auto; height: 1000px">
</div>
Expand Down
4 changes: 2 additions & 2 deletions tests/tree/test_Tree.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Dijit Tree Test</title>
Expand Down Expand Up @@ -36,7 +36,7 @@
</script>

</head>
<body class="claro">
<body class="claro" role="main">

<h1 class="testTitle">Dijit Tree Test</h1>

Expand Down
8 changes: 4 additions & 4 deletions tests/tree/test_Tree_DnD.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Dijit Tree Test</title>
Expand Down Expand Up @@ -136,19 +136,19 @@
</style>

</head>
<body class="claro">
<body class="claro" role="main">
<h1 class="testTitle">Dijit Tree Test - Drag And Drop Support</h1>

<div data-dojo-id="myStore" data-dojo-type="dojo/data/ItemFileWriteStore" data-dojo-props='url:"../_data/categories.json"'></div>

<table style="margin:5px; width:100%;" >
<table style="margin:5px; width:100%;" role="presentation">

<tr style="width:100%">
<td style="width: 50%">
<h2>Custom</h2>
<p>Should add this category to the store. The second parameter is the value for numberOfItems.</p>
<div class="container">
<input id="newCat" type="text" value="Pottedmeat" /><input id="numItems" type="text" value="0" size="3"/><div id="addButton" data-dojo-type="dijit/form/Button">Add Category</div>
<label for="newCat">New category:</label><input id="newCat" type="text" value="Pottedmeat" /><label for="numItems">numberOfItems:</label><input id="numItems" type="text" value="0" size="3"/><div id="addButton" data-dojo-type="dijit/form/Button">Add Category</div>
</div>
</td>
<td>
Expand Down
4 changes: 2 additions & 2 deletions tests/tree/test_Tree_v1.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Dijit Tree V1 API Test</title>
Expand Down Expand Up @@ -28,7 +28,7 @@
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
</script>
</head>
<body class="claro">
<body class="claro" role="main">

<h1 class="testTitle">Dijit Tree V1 API Test</h1>
<p>
Expand Down
8 changes: 0 additions & 8 deletions tree/_dndSelector.js
Expand Up @@ -39,14 +39,6 @@ define([
this.selection={};
this.anchor = null;

if(this.tree.showRoot){
this.tree.domNode.setAttribute("aria-multiselectable", !this.singular);
}else{
// TODO: this will fail in a race condition sometimes, this.tree.rootNode might not exist yet.
// Do not fix with a setTimeout().
// this.tree.rootNode.containerNode.setAttribute("aria-multiselectable", !this.singular);
}

if(!this.cookieName && this.tree.id){
this.cookieName = this.tree.id + "SaveSelectedCookie";
}
Expand Down

0 comments on commit b0d056a

Please sign in to comment.