yui.html revision 1b298c6f0ef597aa4ab0b8bcb25430b6c9a87749
f743002678eb67b99bbc29fee116b65d9530fec0wrowe<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic<script type="text/javascript" src="/build/yui.js"></script>
4da61833a1cbbca94094f9653fd970582b97a72etrawick////////////////////////////////////////////////////////////////////////////
4da61833a1cbbca94094f9653fd970582b97a72etrawick(function() {
4da61833a1cbbca94094f9653fd970582b97a72etrawick var Mod = function(Y) {
4789804be088bcd86ae637a29cdb7fda25169521jailletc Y.example.B = function() {
4789804be088bcd86ae637a29cdb7fda25169521jailletc this.Super.apply(this, arguments);
4789804be088bcd86ae637a29cdb7fda25169521jailletc Y.log("'B' constructor called: " + Array.prototype.splice.call(arguments, 0));
5b88c8507d5ef6d0c4cfbc78230294968175b638minfrin test: function() {
6c3b9cebb551140fbb25d58bae08b539b3802133ylavic Y.log("'B' test called: " + Array.prototype.splice.call(arguments, 0));
0a0df13b7f1f4f1a74fe295253d89ca3911b301aylavic YUI.add("b", Mod, "3.0.0");
69301145375a889e7e37caf7cc7321ac0f91801erpluem////////////////////////////////////////////////////////////////////////////
506bfe33206b2fece40ef25f695af39dd4130facjkaluza(function() {
506bfe33206b2fece40ef25f695af39dd4130facjkaluza var Mod = function(Y) {
d58a848a016d401b965111e50ef829e1641f7834minfrin Y.example.A = function() {
d58a848a016d401b965111e50ef829e1641f7834minfrin // merge the prototype // wonder if this technique would speed inheritance since it // would eliminate lookups in the prototype chain.
2e6f4d654c96c98b761fb012fd25c5d5b1558c44sf Y.log("'A' constructor called: " + Array.prototype.splice.call(arguments, 0));
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavic d: function() { return "foo"; },
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavic toString: function() { return [this.a, this.b, this.c, this.d].join(', '); },
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavic test: function() {
e8bd80a4bb88199d2f9a24a50345688e52d9c116ylavic Y.log("'A' test called: " + Array.prototype.splice.call(arguments, 0));
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic YUI.add("a", Mod, "3.0.0");
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener////////////////////////////////////////////////////////////////////////////
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener(function() {
44ff304057225e944e220e981d434a046d14cf06covener var Mod = function(Y) {
44ff304057225e944e220e981d434a046d14cf06covener Y.example.C = function() {
5d1ba75b8794925e67591c209085a49279791de9covener this.Super.apply(this, arguments);
5d1ba75b8794925e67591c209085a49279791de9covener Y.log("'C' constructor called: " + Array.prototype.splice.call(arguments, 0));
caad2986f81ab263f7af41467dd622dc9add17f3ylavic YUI.add("c", Mod, "3.0.0");
f7317ff316c2b141feea31bddb74d5d3fa1584edjorton////////////////////////////////////////////////////////////////////////////
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem(function() {
1e2d421a36999d292042a5539971070d54aa6c63ylavic // YUI.use('b', 'a'); // order matters in stating deps unless add informs about deps
1e2d421a36999d292042a5539971070d54aa6c63ylavic // YUI.use('a', 'b');
fa7ed98b9dc94c5845cf845aea0a44ecacd290c9humbedooh var y1 = YUI().use('a', 'c');
fa7ed98b9dc94c5845cf845aea0a44ecacd290c9humbedooh var b = new .example.B(1, 2);
5ef3c61605a3a021ff71f488983cb0065f8e1a79covener // shouldn't work
fb1985a97912b25ec6564c73e610a31e5fc6e25fcovener // var c = new YUI.example.C();
6502b7b32f980cc2093bb3ebce37e5e4dc68fba4ylavic // shouldn't work
6502b7b32f980cc2093bb3ebce37e5e4dc68fba4ylavic // var b = new y1.example.B();
c1a63b8fad09c419c1a64f75993feb8a343a6801ylavic var a1 = new YUI.example.A();
c1a63b8fad09c419c1a64f75993feb8a343a6801ylavic a1.b = "a1 change";
e6b4bd1113567627ab6bb6c6a7105e1e01a7d889jailletc var a2 = new y1.example.A();
e6b4bd1113567627ab6bb6c6a7105e1e01a7d889jailletc a2.c = "a2 change";
e466c40e1801982602ee0200c9e8b61cc148742djailletc // add a new version of A, change a prototype function
457468b82e59d01eba00dd9d0817309c8f5e414ejim (function() {
457468b82e59d01eba00dd9d0817309c8f5e414ejim var Mod = function(Y) {
04983e3bd1754764eec7d6bb772fe3b0bf391771jorton Y.example.A = function() {
15660979a30d251681463de2e0584853890082accovener Y.log("'New A' constructor called");
15660979a30d251681463de2e0584853890082accovener // merge the prototype // wonder if this technique would speed inheritance since it // would eliminate lookups in the prototype chain.
cfd9415521847b2f9394fad04fb701cfb955f503rjung d: function() { return "bar"; },
28c31fb73c1264bd1d0ff932573677030b024c7dwrowe toString: function() { return [this.a, this.b, this.c, this.d].join(', '); }
63b9f1f5880391261705f696d7d65507bbe9ace3covener YUI.add("a", Mod, "3.0.0");
49dacedb6c387b786b7911082ff35121a45f414bcovener var y2 = YUI().use('a');
49dacedb6c387b786b7911082ff35121a45f414bcovener var a3 = new y2.example.A();
3c990331fc6702119e4f5b8ba9eae3021aea5265jim console.log('Prototype protected? ' + a2.d() + ", " + a3.d() + " - " + (a2.d() != a3.d()));
fc42512879dd0504532f52fe5d0d0383dda96a1eniq return "changed_d";
0451df5dc50fa5d8b3e07d92ee6a92e36a1181a5niq console.log('Prototype protected? ' + a2.d() + ", " + a3.d() + " - " + (a2.d() != a3.d()));
06b8f183140c8e02e0974e938a05078b511d1603covener<input id="addButton" type="button" value="Add link" />