| 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 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 | 1200 |
| 1201 function overrideAttributeApi(prototype) { | 1201 function overrideAttributeApi(prototype) { |
| 1202 // overrides to implement callbacks | 1202 // overrides to implement callbacks |
| 1203 // TODO(sjmiles): should support access via .attributes NamedNodeMap | 1203 // TODO(sjmiles): should support access via .attributes NamedNodeMap |
| 1204 // TODO(sjmiles): preserves user defined overrides, if any | 1204 // TODO(sjmiles): preserves user defined overrides, if any |
| 1205 var setAttribute = prototype.setAttribute; | 1205 var setAttribute = prototype.setAttribute; |
| 1206 prototype.setAttribute = function(name, value) { | 1206 prototype.setAttribute = function(name, value) { |
| 1207 changeAttribute.call(this, name, value, setAttribute); | 1207 changeAttribute.call(this, name, value, setAttribute); |
| 1208 } | 1208 } |
| 1209 var removeAttribute = prototype.removeAttribute; | 1209 var removeAttribute = prototype.removeAttribute; |
| 1210 prototype.removeAttribute = function(name, value) { | 1210 prototype.removeAttribute = function(name) { |
| 1211 changeAttribute.call(this, name, value, removeAttribute); | 1211 changeAttribute.call(this, name, null, removeAttribute); |
| 1212 } | 1212 } |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 function changeAttribute(name, value, operation) { | 1215 function changeAttribute(name, value, operation) { |
| 1216 var oldValue = this.getAttribute(name); | 1216 var oldValue = this.getAttribute(name); |
| 1217 operation.apply(this, arguments); | 1217 operation.apply(this, arguments); |
| 1218 if (this.attributeChangedCallback | 1218 if (this.attributeChangedCallback |
| 1219 && (this.getAttribute(name) !== oldValue)) { | 1219 && (this.getAttribute(name) !== oldValue)) { |
| 1220 this.attributeChangedCallback(name, oldValue); | 1220 this.attributeChangedCallback(name, oldValue, value); |
| 1221 } | 1221 } |
| 1222 } | 1222 } |
| 1223 | 1223 |
| 1224 // element registry (maps tag names to definitions) | 1224 // element registry (maps tag names to definitions) |
| 1225 | 1225 |
| 1226 var registry = {}; | 1226 var registry = {}; |
| 1227 | 1227 |
| 1228 function registerDefinition(name, definition) { | 1228 function registerDefinition(name, definition) { |
| 1229 if (registry[name]) { | 1229 if (registry[name]) { |
| 1230 throw new Error('Cannot register a tag more than once'); | 1230 throw new Error('Cannot register a tag more than once'); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 // include .host reference | 1430 // include .host reference |
| 1431 if (HTMLElement.prototype.createShadowRoot) { | 1431 if (HTMLElement.prototype.createShadowRoot) { |
| 1432 var originalCreateShadowRoot = HTMLElement.prototype.createShadowRoot; | 1432 var originalCreateShadowRoot = HTMLElement.prototype.createShadowRoot; |
| 1433 HTMLElement.prototype.createShadowRoot = function() { | 1433 HTMLElement.prototype.createShadowRoot = function() { |
| 1434 var root = originalCreateShadowRoot.call(this); | 1434 var root = originalCreateShadowRoot.call(this); |
| 1435 root.host = this; | 1435 root.host = this; |
| 1436 return root; | 1436 return root; |
| 1437 } | 1437 } |
| 1438 } | 1438 } |
| 1439 })(); | 1439 })(); |
| OLD | NEW |