diff --git a/lib/client/dom.js b/lib/client/dom.js index e2e4dacf..d7702c85 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -792,53 +792,51 @@ var CloudCmd, Util, DOM, CloudFunc; return {code: -1, text: 'name can not be empty'}; } } - lElement = document.createElement(lName); + lElement = document.createElement(lName); if (lID) - lElement.id = lID; + lElement.id = lID; if (lClass) - lElement.className = lClass; + lElement.className = lClass; - /* if working with external css - * using href in any other case - * using src - */ - if (lName === 'link'){ - lElement.href = lSrc; - lElement.rel = 'stylesheet'; - }else - lElement.src = lSrc; - - /* - * if passed arguments function - * then it's onload by default - * - * if object - then onload and onerror - */ - - var lLoad = function(pEvent){ - Events.remove('load', lLoad, lElement); - Events.remove('error', lError, lElement); - - Util.exec(lFunc, pEvent); - }, + if(lSrc) { + /* if work with css use href */ + if (lName === 'link'){ + lElement.href = lSrc; + lElement.rel = 'stylesheet'; + }else + lElement.src = lSrc; - lError = function(){ - lParent.removeChild(lElement); - - Images.showError({ - responseText: 'file ' + - lSrc + - ' could not be loaded', - status : 404 - }); + /* + * if passed arguments function + * then it's onload by default + * + * if object - then onload and onerror + */ + var lLoad = function(pEvent){ + Events.remove('load', lLoad, lElement); + Events.remove('error', lError, lElement); + + Util.exec(lFunc, pEvent); + }, - Util.exec(lOnError); - }; - - Events.add('load', lLoad, lElement); - Events.addError(lError, lElement); + lError = function(){ + lParent.removeChild(lElement); + + Images.showError({ + responseText: 'file ' + + lSrc + + ' could not be loaded', + status : 404 + }); + + Util.exec(lOnError); + }; + + Events.add('load', lLoad, lElement); + Events.addError(lError, lElement); + } if (lAttr) for(i in lAttr)