Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: pkg/mutation_observer/lib/mutation_observer.js

Issue 21191006: [pkg:mutation_observer] fix 12132, ie9 support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/mutation_observer/lib/mutation_observer.min.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The Polymer Authors. All rights reserved. 2 * Copyright 2013 The Polymer Authors. All rights reserved.
3 * Use of this source code is goverened by a BSD-style 3 * Use of this source code is goverened by a BSD-style
4 * license that can be found in the LICENSE file. 4 * license that can be found in the LICENSE file.
5 */ 5 */
6 6
7 // TODO(jmesserly): polyfill does not have feature testing or the definition of 7 // TODO(jmesserly): polyfill does not have feature testing or the definition of
8 // SideTable. The extra code is from: 8 // SideTable. The extra code is from:
9 // https://github.com/Polymer/CustomElements/blob/master/src/MutationObserver.js 9 // https://github.com/Polymer/CustomElements/blob/master/src/MutationObserver.js
10 // https://github.com/Polymer/CustomElements/blob/master/src/sidetable.js 10 // https://github.com/Polymer/CustomElements/blob/master/src/sidetable.js
11 // I also renamed JsMutationObserver -> MutationObserver to correctly interact 11 // I also renamed JsMutationObserver -> MutationObserver to correctly interact
12 // with dart2js interceptors. 12 // with dart2js interceptors.
13
13 if (!window.MutationObserver && !window.WebKitMutationObserver) { 14 if (!window.MutationObserver && !window.WebKitMutationObserver) {
14 15
15 (function(global) { 16 (function(global) {
16 // SideTable is a weak map where possible. If WeakMap is not available the 17 // SideTable is a weak map where possible. If WeakMap is not available the
17 // association is stored as an expando property. 18 // association is stored as an expando property.
18 var SideTable; 19 var SideTable;
19 // TODO(arv): WeakMap does not allow for Node etc to be keys in Firefox 20 // TODO(arv): WeakMap does not allow for Node etc to be keys in Firefox
20 if (typeof WeakMap !== 'undefined' && navigator.userAgent.indexOf('Firefox/') < 0) { 21 if (typeof WeakMap !== 'undefined' && navigator.userAgent.indexOf('Firefox/') < 0) {
21 SideTable = WeakMap; 22 SideTable = WeakMap;
22 } else { 23 } else {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 * @constructor 177 * @constructor
177 */ 178 */
178 function MutationObserver(callback) { 179 function MutationObserver(callback) {
179 this.callback_ = callback; 180 this.callback_ = callback;
180 this.nodes_ = []; 181 this.nodes_ = [];
181 this.records_ = []; 182 this.records_ = [];
182 this.uid_ = ++uidCounter; 183 this.uid_ = ++uidCounter;
183 } 184 }
184 185
185 MutationObserver.prototype = { 186 MutationObserver.prototype = {
186 // TODO(jmesserly): why is this necessary?
187 get constructor() { return MutationObserver; },
188
189 observe: function(target, options) { 187 observe: function(target, options) {
190 target = wrapIfNeeded(target); 188 target = wrapIfNeeded(target);
191 189
192 // 1.1 190 // 1.1
193 if (!options.childList && !options.attributes && !options.characterData || 191 if (!options.childList && !options.attributes && !options.characterData ||
194 192
195 // 1.2 193 // 1.2
196 options.attributeOldValue && !options.attributes || 194 options.attributeOldValue && !options.attributes ||
197 195
198 // 1.3 196 // 1.3
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 this.target = target; 269 this.target = target;
272 this.addedNodes = []; 270 this.addedNodes = [];
273 this.removedNodes = []; 271 this.removedNodes = [];
274 this.previousSibling = null; 272 this.previousSibling = null;
275 this.nextSibling = null; 273 this.nextSibling = null;
276 this.attributeName = null; 274 this.attributeName = null;
277 this.attributeNamespace = null; 275 this.attributeNamespace = null;
278 this.oldValue = null; 276 this.oldValue = null;
279 } 277 }
280 278
279 // TODO(jmesserly): this fixes the interceptor dispatch on IE.
280 // Not sure why this is necessary.
281 MutationObserver.prototype.constructor = MutationObserver;
282 MutationObserver.name = 'MutationObserver';
283 MutationRecord.prototype.constructor = MutationRecord;
284 MutationRecord.name = 'MutationRecord';
285
281 function copyMutationRecord(original) { 286 function copyMutationRecord(original) {
282 var record = new MutationRecord(original.type, original.target); 287 var record = new MutationRecord(original.type, original.target);
283 record.addedNodes = original.addedNodes.slice(); 288 record.addedNodes = original.addedNodes.slice();
284 record.removedNodes = original.removedNodes.slice(); 289 record.removedNodes = original.removedNodes.slice();
285 record.previousSibling = original.previousSibling; 290 record.previousSibling = original.previousSibling;
286 record.nextSibling = original.nextSibling; 291 record.nextSibling = original.nextSibling;
287 record.attributeName = original.attributeName; 292 record.attributeName = original.attributeName;
288 record.attributeNamespace = original.attributeNamespace; 293 record.attributeNamespace = original.attributeNamespace;
289 record.oldValue = original.oldValue; 294 record.oldValue = original.oldValue;
290 return record; 295 return record;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 579 }
575 580
576 clearRecords(); 581 clearRecords();
577 } 582 }
578 }; 583 };
579 584
580 global.MutationObserver = MutationObserver; 585 global.MutationObserver = MutationObserver;
581 })(window); 586 })(window);
582 587
583 } 588 }
OLDNEW
« no previous file with comments | « no previous file | pkg/mutation_observer/lib/mutation_observer.min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698