Closed Bug 138708 Opened 22 years ago Closed 22 years ago

Cannot write to a property. Looks like a bug. See the description

Categories

(Core :: JavaScript Engine, defect)

x86
Windows 98
defect
Not set
critical

Tracking

()

VERIFIED DUPLICATE of bug 137000

People

(Reporter: rustam, Assigned: rogerl)

Details

Attachments

(1 file)

<html>
<head>
<META http-equiv="Content-Type" content="text/html" > 


	<title> Is it a bug? </title>

</head>


<body>
for Nav4, IE4up, Nav6.2 and Opera the last this.id==child1<br>
for Mozilla it's undefined, what's wrong?
<br>
the script is:<br>
<br>
function Base(id){<br>
alert('this is a Base Constructor, parameter id='+id)<br>
this.id=id;<br>
alert('intializing the id property: this.id='+this.id);<br>
}<br>
<br>
function Child(id) {<br>
alert('this is a Child constructor, with parameter id='+id+', now going into 
the Base constructor')<br>
this.bas=Base;this.bas(id);<br>
}<br>
Child.prototype=Base;<br>


b1=new Base('base1');<br>
b2=new Base('base2');<br>
c1=new Child('child1');<br>


<script language="JavaScript">


function Base(id){
alert('this is a Base Constructor, parameter id='+id)
this.id=id;
alert('intializing the id property: this.id='+this.id);
}

function Child(id) {
alert('this is a Child constructor, with parameter id='+id+', now going into 
the Base constructor')
this.bas=Base;this.bas(id);
}
Child.prototype=Base;




b1=new Base('base1');
b2=new Base('base2');
c1=new Child('child1');

</script> 
</body>
</html>
Mozilla's behavior strangely different form the one of Nav4, Nav6, IE4up and
Opera
This also (and a little more simply) happens with :

function Base(id){}

function Child(id) {
this.id = id; 
print(this.id);
}
Child.prototype=Base;

c1=new Child('child1');


The reference in 'Child' to 'id' is getting resolved to the 'id' argument of the
prototype 'Base' function object. (You can see this by changing the first line to
'function Base(a){}' instead). 
This looks like a duplicate of bug 137000, 
"Object member variables not set correctly from parameters passed to parent"

In that bug, too, the key point is using the same name for the
parameter to the Base() and Child() constructors. 






*** This bug has been marked as a duplicate of 137000 ***
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
Marking Verified Duplicate.

Rustam, thank you for this report. You have been cc'ed on
the duplicate bug, so that you may follow its progress -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: