|
63 | 63 | this.publishProperties(prototype, base);
|
64 | 64 | // infer observers for `observe` list based on method names
|
65 | 65 | this.inferObservers(prototype);
|
66 |
| - // chain observe object |
67 |
| - chainObject(prototype.observe, base.observe); |
68 |
| - // chain publish object |
69 |
| - chainObject(prototype.publish, base.publish); |
| 66 | + // chain various meta-data objects to inherited versions |
| 67 | + this.inheritMetaData(prototype, base); |
| 68 | + // chain custom api to inherited |
| 69 | + prototype = this.chainObject(prototype, base); |
70 | 70 | // build side-chained lists to optimize iterations
|
71 | 71 | this.optimizePropertyMaps(prototype, base);
|
72 |
| - // chain custom api |
73 |
| - chainObject(prototype, base); |
74 | 72 | // inherit publishing meta-data
|
75 |
| - this.inheritAttributesObjects(prototype); |
76 |
| - this.inheritDelegates(prototype); |
| 73 | + //this.inheritAttributesObjects(prototype); |
| 74 | + //this.inheritDelegates(prototype); |
77 | 75 | // x-platform fixups
|
78 | 76 | ensurePrototypeTraversal(prototype);
|
79 | 77 | return prototype;
|
80 | 78 | },
|
| 79 | + inheritMetaData: function(prototype, base) { |
| 80 | + // chain observe object to inherited |
| 81 | + this.inheritObject('observe', prototype, base); |
| 82 | + // chain publish object to inherited |
| 83 | + this.inheritObject('publish', prototype, base); |
| 84 | + // chain our lower-cased publish map to the inherited version |
| 85 | + this.inheritObject('_publishLC', prototype, base); |
| 86 | + // chain our instance attributes map to the inherited version |
| 87 | + this.inheritObject('_instanceAttributes', prototype, base); |
| 88 | + // chain our event delegates map to the inherited version |
| 89 | + this.inheritObject('eventDelegates', prototype, base); |
| 90 | + }, |
81 | 91 | // implement various declarative features
|
82 | 92 | desugar: function(prototype) {
|
83 | 93 | // compile list of attributes to copy to instances
|
|
129 | 139 | // return buffed-up prototype
|
130 | 140 | return prototype;
|
131 | 141 | },
|
132 |
| - // make a fresh object that inherits from a prototype object |
133 |
| - inheritObject: function(prototype, name) { |
134 |
| - // copy inherited properties onto a new object |
135 |
| - prototype[name] = extend({}, Object.getPrototypeOf(prototype)[name]); |
| 142 | + // ensure prototype[name] inherits from a prototype.prototype[name] |
| 143 | + inheritObject: function(name, prototype, base) { |
| 144 | + // require an object |
| 145 | + var source = prototype[name] || {}; |
| 146 | + // chain inherited properties onto a new object |
| 147 | + prototype[name] = this.chainObject(source, base[name]); |
136 | 148 | },
|
137 | 149 | // register 'prototype' to custom element 'name', store constructor
|
138 | 150 | registerPrototype: function(name) {
|
|
147 | 159 | }
|
148 | 160 | };
|
149 | 161 |
|
| 162 | + if (Object.__proto__) { |
| 163 | + prototype.chainObject = function(object, inherited) { |
| 164 | + if (object && inherited && object !== inherited) { |
| 165 | + object.__proto__ = inherited; |
| 166 | + } |
| 167 | + return object; |
| 168 | + } |
| 169 | + } else { |
| 170 | + prototype.chainObject = function(object, inherited) { |
| 171 | + if (object && inherited && object !== inherited) { |
| 172 | + var chained = Object.create(inherited); |
| 173 | + object = extend(chained, object); |
| 174 | + } |
| 175 | + return object; |
| 176 | + } |
| 177 | + } |
| 178 | + |
150 | 179 | // memoize base prototypes
|
151 | 180 | memoizedBases = {};
|
152 | 181 |
|
|
0 commit comments