Files
polymer/workbench/oop/extend.html
T
2013-05-13 18:07:25 -07:00

45 lines
985 B
HTML

<!DOCTYPE html>
<!--
Copyright 2013 The Polymer-Project Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
<head>
<title>lib::extend</title>
<script src="../../lib/oop.js"></script>
</head>
<body>
<script>
Base = function() {};
Base.prototype = {
super: $super,
emit: function(inMsg) {
document.body.appendChild(document.createTextNode(inMsg));
},
soundOff: function() {
this.emit('[Base]');
}
};
//
Sub = function() {};
Sub.prototype = extend(Base.prototype, {
soundOff: function() {
this.emit('[Sub]');
this.super();
}
});
//
SubSub = function() {};
SubSub.prototype = extend(Sub.prototype, {
soundOff: function() {
this.emit('[SubSub]');
this.super();
}
});
//
subsub = new SubSub();
subsub.soundOff();
</script>
</body>
</html>