Permalink
Browse files

Fixes uncaught exception in memory plugin on IE6/7

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.
  • Loading branch information...
1 parent 67e1998 commit 2eb2a6e02032623e9cce96feab30ac47e62b1ec6 @jonpliske jonpliske committed Jan 4, 2013
Showing with 11 additions and 7 deletions.
  1. +11 −7 plugins/memory.js
View
@@ -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) {
@@ -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();

0 comments on commit 2eb2a6e

Please sign in to comment.