SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: xInnerHtml

  1. #1
    SitePoint Addict dek's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    xInnerHtml

    I guess this one's for Mike Foster...

    Just upgraded to the latest version of the ever-amazing 'x' library (was on 3.15.2 before) - and I notice to my dismay that xInnerHtml seems to have vanished from x_core.js (still in x_core_n4.js) - is this a temporary glitch, or a permanent loss?

    Ta,

    Andy
    Only dead fish go with the flow

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Andy,

    Thanks!

    The following is xInnerHtml, from x_core_n4.js. The only thing "cross-browser" about it is support for NN4. Beginning with version 3.15 I removed all NN4 support (it remains in files with "_n4" suffix). That's why I thought it should be removed from x_core.js.
    Code:
    function xInnerHtml(e, sHtml) {
      if(!(e=xGetElementById(e))) return '';
      if (xStr(e.innerHTML)) {
        if (xStr(sHtml)) e.innerHTML = sHtml;
        else return e.innerHTML;
      }
      else if (xNN4) {
        if (xStr(sHtml)) {
          if (sHtml=='') sHtml = ' ';
          e.document.open();
          e.document.write(sHtml);
          e.document.close();
        }
        else return '';
      }
    }
    After removing NN4 support there's not much left of the function. Do you really think it should be returned to x_core.js?

    Btw, this function has some problems that I'm slowly identifying and correcting in several of the functions. Notice that it returns a value sometimes - but not all the time. Notice that it returns an error value which is in the solution domain - it probably should return null on error.

  3. #3
    SitePoint Addict dek's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting. I guess I hadn't really looked closely enough at it...

    Personally, I'd say that it probably belongs in x_dom.js, but I would suggest keeping it somewhere in x - partly as it was there before, and partly because it does supply a nice little bit of syntactic sugar which is pretty useful.

    I'd suggest that if sHTML is specified, it returns the old value of innerHTML, before the new value was put in - but that's just my own preference.

    Anyway - thanks for clarifying that,

    Andy
    Only dead fish go with the flow


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •