Skip to content

Commit

Permalink
Fixes uncaught exception in memory plugin on IE6/7
Browse files Browse the repository at this point in the history
The memory plugin uses document.getElementsByTagName in order to count
the number of certain types of DOM elements. It uses (function).call() to
do this. In IE6/7 the getElementsByTagName is not a typical function and
does not have call(). This patch wraps the underlying function in an
anonymous function when call() is missing.
(cherry picked from commit 2eb2a6e)

Signed-off-by: Philip Tellis <philip.tellis@gmail.com>
  • Loading branch information
jonpliske authored and bluesmoon committed Jan 25, 2013
1 parent 43a8e88 commit f689671
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions plugins/memory.js
Expand Up @@ -19,13 +19,17 @@ BOOMR.plugins = BOOMR.plugins || {};
var impl = {
complete: false,
done: function() {
var w = BOOMR.window,
p = w.performance,
c = w.console,
d = w.document,
f = (({}).toString.call(w.opera) == '[object Opera]' ? d.querySelectorAll : d.getElementsByTagName),
var w = BOOMR.window,
p = w.performance,
c = w.console,
d = w.document,
_f = (({}).toString.call(w.opera) == '[object Opera]' ? d.querySelectorAll : d.getElementsByTagName),
m;

// handle IE6/7 weirdness regarding host objects
// See: http://stackoverflow.com/questions/7125288/what-is-document-getelementbyid
var f = (typeof _f.call === 'undefined' ? function(tag) { return _f(tag) } : _f);

m = (p && p.memory ? p.memory : (c && c.memory ? c.memory : null));

if(m) {
Expand All @@ -35,13 +39,13 @@ var impl = {
});
}


BOOMR.addVar({
'dom.ln': f.call(d, '*').length,
'dom.sz': f.call(d, 'html')[0].innerHTML.length,
'dom.img': f.call(d, 'img').length,
'dom.script': f.call(d, 'script').length
});
});

this.complete = true;
BOOMR.sendBeacon();
Expand Down

0 comments on commit f689671

Please sign in to comment.