__defineSetter__ removes the value attribute from an INPUT tag

RESOLVED INVALID

Status

()

RESOLVED INVALID
15 years ago
5 months ago

People

(Reporter: gerbert, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

15 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030827
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030827

When attaching a function to the value property of an input tag by using
__defineSetter__ . The property itself is removed from the object:
oInput.value == 'undefined'

However the value can still be accessed through oInput.getAttribute('value')
When I set the value (oInput.value = 'something') the setter is NOT called.

Running code example:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
</head>

<script type="text/javascript">

function Add_Setter(oObj,sProp) {
	oObj.__defineSetter__(sProp, function (sVal) { alert(this + ": " + sProp + " =
" + sVal); });
}


function GO() {
	var oObj = document.getElementById("zebra");

	Add_Setter(oObj, "value");

	oObj.setAttribute("value", "notw00t");

	alert(oObj.getAttribute("value"));  // Returns 'notw00t'
	alert(oObj.value);                  // Returns undefined
}

</script>

<body onload="GO();">

<form>
<input type="text" name="zebra" id="zebra" value="w00t" /><br />
</form>

</body>
</html>



Reproducible: Always

Steps to Reproduce:
1. See code example
2.
3.

Actual Results:  
the value property is gone.. the setter is not called

Expected Results:  
Not remove the value property! :) Call the setter
(Reporter)

Comment 1

15 years ago
Hmm.. Neil on Moznet helped me by adding

oObj.__defineGetter__("value", oObj.__lookupGetter__("value"));

this seems to eliminate the undefind problem. I still find his wierd
though. Having to set the getter when I only want the setter. :)
Anyway.. typing in the input field still does not trigger my Func. :(
This is an xpconnect/dom issue with the way the DOM objects are bound to JS...
Assignee: rogerl → BradleyJunk
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → XPConnect
Ever confirmed: true
Assignee: dbradley → nobody
QA Contact: pschwartau → xpconnect

Comment 3

5 months ago
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Last Resolved: 5 months ago
Resolution: --- → INACTIVE
Invalid; that's just how accessor properties work in ES.
Resolution: INACTIVE → INVALID
You need to log in before you can comment on or make changes to this bug.