| OLD | NEW |
| 1 // Copyright (c) 2012 The Polymer Authors. All rights reserved. | 1 // Copyright (c) 2012 The Polymer Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
| 4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
| 5 // met: | 5 // met: |
| 6 // | 6 // |
| 7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
| 8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
| 9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
| 10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
| (...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 | 1144 |
| 1145 function implement(element, definition) { | 1145 function implement(element, definition) { |
| 1146 // prototype swizzling is best | 1146 // prototype swizzling is best |
| 1147 if (Object.__proto__) { | 1147 if (Object.__proto__) { |
| 1148 element.__proto__ = definition.prototype; | 1148 element.__proto__ = definition.prototype; |
| 1149 } else { | 1149 } else { |
| 1150 // where above we can re-acquire inPrototype via | 1150 // where above we can re-acquire inPrototype via |
| 1151 // getPrototypeOf(Element), we cannot do so when | 1151 // getPrototypeOf(Element), we cannot do so when |
| 1152 // we use mixin, so we install a magic reference | 1152 // we use mixin, so we install a magic reference |
| 1153 customMixin(element, definition.prototype, definition.native); | 1153 customMixin(element, definition.prototype, definition.native); |
| 1154 |
| 1155 // Dart note: make sure we pick up the right constructor. |
| 1156 // dart2js depends on this for dart:mirrors caching to work. |
| 1157 // See tests/html/custom/mirrors_test.dart |
| 1158 element.constructor = definition.prototype.constructor; |
| 1154 element.__proto__ = definition.prototype; | 1159 element.__proto__ = definition.prototype; |
| 1155 } | 1160 } |
| 1156 } | 1161 } |
| 1157 | 1162 |
| 1158 function customMixin(inTarget, inSrc, inNative) { | 1163 function customMixin(inTarget, inSrc, inNative) { |
| 1159 // TODO(sjmiles): 'used' allows us to only copy the 'youngest' version of | 1164 // TODO(sjmiles): 'used' allows us to only copy the 'youngest' version of |
| 1160 // any property. This set should be precalculated. We also need to | 1165 // any property. This set should be precalculated. We also need to |
| 1161 // consider this for supporting 'super'. | 1166 // consider this for supporting 'super'. |
| 1162 var used = {}; | 1167 var used = {}; |
| 1163 // start with inSrc | 1168 // start with inSrc |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 if (window.CustomElements && !CustomElements.useNative) { | 1488 if (window.CustomElements && !CustomElements.useNative) { |
| 1484 var originalImportNode = Document.prototype.importNode; | 1489 var originalImportNode = Document.prototype.importNode; |
| 1485 Document.prototype.importNode = function(node, deep) { | 1490 Document.prototype.importNode = function(node, deep) { |
| 1486 var imported = originalImportNode.call(this, node, deep); | 1491 var imported = originalImportNode.call(this, node, deep); |
| 1487 CustomElements.upgradeAll(imported); | 1492 CustomElements.upgradeAll(imported); |
| 1488 return imported; | 1493 return imported; |
| 1489 } | 1494 } |
| 1490 } | 1495 } |
| 1491 | 1496 |
| 1492 })(); | 1497 })(); |
| OLD | NEW |