From 84a8e79b21948f2d12e92524c624042175cff08b Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sat, 8 Feb 2014 21:44:53 -0600 Subject: [PATCH] create dom trace debug tool --- js/ext/angular/test/dom-trace.js | 238 +++++++++++++++++++++++++++++ js/ext/angular/test/viewState.html | 3 + 2 files changed, 241 insertions(+) create mode 100644 js/ext/angular/test/dom-trace.js diff --git a/js/ext/angular/test/dom-trace.js b/js/ext/angular/test/dom-trace.js new file mode 100644 index 0000000000..d4ba419ef5 --- /dev/null +++ b/js/ext/angular/test/dom-trace.js @@ -0,0 +1,238 @@ + +(function(){ + + function logMutation(m) { + if(m.type == 'attributes') { + attributeMutation(m); + } else if(m.type == 'childList') { + childListMutation(m); + } else if(m.type == 'characterData') { + characterDataMutation(m); + } else if(m.type == 'subtree') { + attributeMutation(m); + } else { + console.debug(m); + } + } + + function attributeMutation(m) { + // target's attributes are to be observed. + if(m.attributeName == 'class') { + var msgs = []; + + msgs.push( 'Class, ' + createElementId(m.target) ); + + if(m.oldValue !== m.target.className) { + var exisitingClasses = (m.oldValue ? m.oldValue.split(' ') : []); + var currentClasses = m.target.className.split(' '); + var addedClasses = []; + var removedClasses = []; + + for(var x=0; x + @@ -379,6 +380,8 @@ }); + domTrace.observe(); +