Opened 6 years ago

Closed 5 years ago

#17585 closed defect (invalid)

dijit/form/_FormSelectWidget: this.options might be NodeList

Reported by: sunxcint Owned by: sunxcint
Priority: undecided Milestone: tbd
Component: Dijit - Form Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:

Description

In _fillContent() of dijit/form/_FormSelectWidget, if query("> *", this.srcNodeRef) returns a NodeList with zero members, this.options will just be set as this zero-length NodeList, which could be the case when coding declaratively with a store as the data provider.

Even current code works(thanks to duck-typing), it will bring much confusion and difficulties to users taking this module as a base class. I suggest an empty array(i.e. []) be returned directly if this.store is not null(or in any cases where query("> *", this.srcNodeRef) might return a zero-length NodeList).

Change History (2)

comment:1 Changed 5 years ago by bill

Owner: set to sunxcint
Status: newpending

Are you saying that zero members (as contrasted with, for example, 5 members) is a special case?

I looked at the current code and AFAICT it calls map() regardless of how many elements there are:

this.options =
	this.srcNodeRef
		? query("> *", this.srcNodeRef).map(
		function(node){
			if(node.getAttribute("type") === "separator"){
				return { value: "", label: "", selected: false, disabled: false };
			}
			return {
				value: (node.getAttribute("data-" + kernel._scopeName + "-value") || node.getAttribute("value")),
				label: String(node.innerHTML),
				// FIXME: disabled and selected are not valid on complex markup children (which is why we're
				// looking for data-dojo-value above.  perhaps we should data-dojo-props="" this whole thing?)
				// decide before 1.6
				selected: node.getAttribute("selected") || false,
				disabled: node.getAttribute("disabled") || false
			};
		},
		this)
		: [];
```

comment:2 Changed 5 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.