Closed jambonnade closed 9 years ago
I forgot to mention : doesn't happen if firebug (or dev console) is opened. I believe firebug accesses the created objects in some way ; that's why, i added "Object.keys()" to fix, it may do the same kind of stuff internally.
@Gruikmusic , interesting bug, did you post a report at bugzilla.mozilla.org ? i can reproduce this without prototype.js :
<script>
function SuperClass() {
this.meth1();
var z = this.data3;
this.meth2();
if (z !== this.data3) {
alert('bug!');
}
}
SuperClass.prototype.meth1 = function () {
};
SuperClass.prototype.meth2 = function () {
this.data4 = 'x';
};
var F = function () {
};
F.prototype = SuperClass.prototype;
function SubClassA() {
SuperClass.call(this);
}
SubClassA.prototype = new F();
SubClassA.prototype.meth1 = function () {
this.data3 = 'z';
};
SubClassA.prototype.meth2 = function () {
};
function SubClassB() {
SuperClass.call(this);
}
SubClassB.prototype = new F();
new SubClassB();
new SubClassA();
</script>
i prefered to let you (prototypejs contributors) report to mozilla when found whether it's related to firefox or prototypejs
@Gruikmusic , so you have to wait prototypejs contributors to do this.... Anyway, i think, it is not good, that common constructor creates different properties on an object, because of redefined "meth1" and "meth2"...
I reported to mozilla https://bugzilla.mozilla.org/show_bug.cgi?id=1008339
About derived methods in constructor, I'm used to do this in PHP and I find it interesting :
class Parent
{
public function __construct($params)
{
// [...]
$this->_initSomeStuff();
$this->_initOtherStuff();
// [...]
}
protected function _initSomeStuff()
{
// default code
}
protected function _initOtherStuff()
{
// default code
}
}
_initSomeStuff and _initOtherStuff may be overridden then in subclasses to customize some parts of initialization while keeping a common construction (and a common constructor signature)
I reported to mozilla https://bugzilla.mozilla.org/show_bug.cgi?id=1008339
good. ;
About derived methods in constructor, I'm used to do this in PHP and I find it interesting : Thats OK.
But in javascript the sequence of property assignments affects the "class" of an object. So, it is better to define all properties in the constructor.
Looks like Firefox fixed this, which is good, because I wouldn't have known where to start. Thanks!
Hi,
We have a bug that appeared with Firefox 29 : some property in one object is lost when calling a redefined method. The conditions to reproduce are very particular but I identified them. Maybe it may lead to identify a bigger problem.
Here is the code