Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dist/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@
{
superClass = window.include(superClass);
}
subClass.prototype = superClass.prototype;
subClass.prototype.__parent = superClass.prototype;
subClass.prototype = Object.create(
superClass.prototype
subClass.prototype
);
return subClass.prototype;
};

}(window));
}(window));
2 changes: 1 addition & 1 deletion dist/namespace.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
{
superClass = window.include(superClass);
}
subClass.prototype = superClass.prototype;
subClass.prototype.__parent = superClass.prototype;
subClass.prototype = Object.create(
superClass.prototype
subClass.prototype
);
return subClass.prototype;
};

}(window));
}(window));
20 changes: 19 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@
assert.ok(o instanceof ParentClass, "Inherit parent class");

});

test('extend.parent', function(assert){
expect(3);

var ParentClass = function(){};
ParentClass.prototype.ping = function(){return "parent";}
var MyClass = function(){};

extend(MyClass, ParentClass);
MyClass.prototype.ping = function(){return "child";}

var o = new MyClass();

assert.ok(o.ping() === "child", "Child function");
assert.ok(o.__parent.ping.apply(o) === "parent", "Parent function");
assert.ok(o.ping() !== o.__parent.ping.apply(o), "Child != Parent function");

});
</script>
</body>
</html>
</html>