From 80609a1a2ca566d7a93314cb00d2b4c1cc13f3b1 Mon Sep 17 00:00:00 2001 From: tleish Date: Wed, 26 Mar 2014 21:17:56 -0600 Subject: [PATCH] Fixing ie8 'Uncaught TypeError' I occasionally get the following error in IE8. > Uncaught TypeError: Cannot set property 'w' of undefined: line #198 Fixed by adding a condition to function new_handler. --- jquery.ba-resize.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/jquery.ba-resize.js b/jquery.ba-resize.js index 1f41d37..fc2958b 100644 --- a/jquery.ba-resize.js +++ b/jquery.ba-resize.js @@ -192,13 +192,15 @@ var elem = $(this), data = $.data( this, str_data ); - // If called from the polling loop, w and h will be passed in as - // arguments. If called manually, via .trigger( 'resize' ) or .resize(), - // those values will need to be computed. - data.w = w !== undefined ? w : elem.width(); - data.h = h !== undefined ? h : elem.height(); - - old_handler.apply( this, arguments ); + if(data){ + // If called from the polling loop, w and h will be passed in as + // arguments. If called manually, via .trigger( 'resize' ) or .resize(), + // those values will need to be computed. + data.w = w !== undefined ? w : elem.width(); + data.h = h !== undefined ? h : elem.height(); + + old_handler.apply( this, arguments ); + } }; // This may seem a little complicated, but it normalizes the special event