MDL-36609 javascript: ensure HTML element exists before attempting to perform JS functionality

This commit is contained in:
Mark Nelson
2012-11-19 15:43:12 +08:00
parent 6548ce0915
commit 302808a37f
+9 -4
View File
@@ -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() {