Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#6126 closed defect (invalid)

dijit.tree.TreeStoreModel.mayHaveChildren incorrectly implemented

Reported by: guest Owned by:
Priority: high Milestone:
Component: Dijit Version: 1.1b1
Keywords: mayHaveChildren, TreeStoreModel, ForestStoreModel Cc:
Blocked By: Blocking:

Description

The current implementation uses: return dojo.some(this.childrenAttr, function(attr){

return this.store.hasAttribute(item, attr);

}, this);

but as this.childrenAttr is a string, every character is treated as an element of an array. For a childrenAttr like 'children', the function that will be executed is

return this.store.hasAttribute(item, 'c') return this.store.hasAttribute(item, 'h') return this.store.hasAttribute(item, 'i') ...

The correct, expected behaviour, occurs when wrapping the value this.childrenAttr in an Array, thus using the implementation:

return dojo.some([this.childrenAttr], function(attr){

return this.store.hasAttribute(item, attr);

}, this);

Change History (5)

comment:1 Changed 11 years ago by bill

Resolution: invalid
Status: newclosed

No, it's an array, see the declaration:

	// childrenAttr: String
	//		one ore more attributes that holds children of a tree node
	childrenAttr: ["children"],

comment:2 Changed 11 years ago by bill

PS: but I will change the variable name to be childrenAttrs so it's less confusing. Plus fix the comment to say String{].

comment:3 Changed 11 years ago by bill

(In [12981]) Refs #6126, #6127: fix comment for childrenAttr to note that it's an array, plus change name to childrenAttrs to be less confusing. !strict

comment:4 Changed 11 years ago by bill

(In [12982]) Refs #6126, #6127: change name to childrenAttrs to be less confusing (except for Tree widget itself, for back compat) !strict

comment:5 Changed 11 years ago by bill

(In [12984]) Refs #6126, #6127: Fix bug in testcase; childrenAttrs is an array so needs to be passed in as such.

Note: See TracTickets for help on using tickets.