Closed Bug 644496 Opened 14 years ago Closed 14 years ago

Events calling javascript function named "list" will return undefined function

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
minor

Tracking

()

RESOLVED INVALID

People

(Reporter: jensantg, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0
Build Identifier: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0

When calling a custom javascript function called "list" in onClick or onChange events, it returns "function is undefined".

If you rename the "list" as something else, say "test", then it works.

However, if it is used under <select> elements, it still works, even when the function name is called "list".

Renaming the function or nesting the function can resolve the problem. So it should be a minor bug.

Reproducible: Always

Steps to Reproduce:
1. Copy the following and save as an HTML file
<script type="text/javascript">
function list() 
{
	alert('test');
	return;
}
</script>
Test Button:<br>
<input type="button" value="Test" onClick="javascript:try{list();} catch (err){alert(err.description);}"/>
<br><br>

Test CheckBox: <br>
<input type="checkbox" value="test" onChange="javascript:try{list();} catch (err){alert(err.description);}"/>Test
<br><br>

Test TextBox: <br>
<input type="text" value="test" onChange="javascript:try{list();} catch (err){alert(err.description);}"/>
<br><br>

Test ComboBox: <br>
<select onChange="javascript:try{list();} catch (err){alert(err.description);}">
<option>a</option>
<option>b</option>
</select>

2. Open the file

3. Try changing the value of each test
Actual Results:  
All tests return error "undefined", except the combo box test

Expected Results:  
All tests should display alert message "test", instead of having errors
2. Open the file 
The file should be opened with FireFox 4.
Regression Range : 
works:
Mozilla/5.0 (Windows NT 6.1; rv:2.0b6pre) Gecko/20100909 Firefox/4.0b6pre
broken:
Mozilla/5.0 (Windows NT 6.1; rv:2.0b6pre) Gecko/20100910 Firefox/4.0b6pre
pushlog:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=8e0fce7d5b49&tochange=79d0beec27b5
Status: UNCONFIRMED → NEW
Ever confirmed: true
(In reply to comment #2)
> Regression Range : 
> works:
> Mozilla/5.0 (Windows NT 6.1; rv:2.0b6pre) Gecko/20100909 Firefox/4.0b6pre
> broken:
> Mozilla/5.0 (Windows NT 6.1; rv:2.0b6pre) Gecko/20100910 Firefox/4.0b6pre
> pushlog:
> http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=8e0fce7d5b49&tochange=79d0beec27b5

That is probably bug 556007
This appears to me to be correct as list is an new attribute on the input element.

https://developer.mozilla.org/en/DOM/HTMLInputElement#Properties
http://dev.w3.org/html5/spec/common-input-element-attributes.html#common-input-element-apis
Component: General → DOM: Core & HTML
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → Trunk
(In reply to comment #4)
> This appears to me to be correct as list is an new attribute on the input
> element.
> 
> https://developer.mozilla.org/en/DOM/HTMLInputElement#Properties
> http://dev.w3.org/html5/spec/common-input-element-attributes.html#common-input-element-apis

Indeed. All browsers supporting the list attribute should have the same behavior. On top of my head, that only includes Opera (maybe Webkit trunk). You can try to do the same test with 'type' instead of 'list' and it should fail for all browsers.
Status: NEW → RESOLVED
Closed: 14 years ago
OS: Windows XP → All
Hardware: x86 → All
Resolution: --- → INVALID
<sigh>.  The "stick the node on the scope chain" thing strikes again....

Jensan, you can use window.list to make it work no matter what.
Thanks for the efforts. I haven't read any HTML5 document yet, so I thought it is a bug.

Anyway I have already fixed it by renaming the list() to listXXX() since I do the test. But list(), perhaps, is a common name for websites, and probably some others will report this as a bug as well. Just want to see if there is any quick fix.

Thanks.
You need to log in before you can comment on or make changes to this bug.