Permalink
Browse files

MDL-36609 javascript: ensure HTML element exists before attempting to…

… perform JS functionality
  • Loading branch information...
markn86 committed Nov 19, 2012
1 parent 6548ce0 commit 302808a37fa8c1da004c5159c38475f9bff4675f
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/javascript-static.js
View
@@ -333,11 +333,16 @@ M.util.init_maximised_embed = function(Y, id) {
if (Y.Lang.isString(el)) {
el = Y.one('#' + el);
}
- var val = el.getStyle(prop);
- if (val == 'auto') {
- val = el.getComputedStyle(prop);
+ // Ensure element exists.
+ if (el) {
+ var val = el.getStyle(prop);
+ if (val == 'auto') {
+ val = el.getComputedStyle(prop);
+ }
+ return parseInt(val);
+ } else {
+ return 0;
}
- return parseInt(val);
};
var resize_object = function() {

0 comments on commit 302808a

Please sign in to comment.