Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

… perform JS functionality
  • Loading branch information...
commit 62d210515cef2b4603b0b5c2089c6db9ec59a1b6 1 parent 2d7c5ee
@markn86 markn86 authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/javascript-static.js
View
13 lib/javascript-static.js
@@ -340,11 +340,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() {
Please sign in to comment.
Something went wrong with that request. Please try again.