Bug Tracker

Ticket #2228: patch

File patch, 2.6 KB (added by mikesamuel, 14 years ago)

Patch

  • third_party/js/jqueryjs/runtest/env.js

     
    190190    get innerHTML(){
    191191      return this.documentElement.outerHTML;
    192192    },
     193    get title() {
     194      var titleNode = this.getElementsByTagName("title")[0];
     195      return titleNode ? titleNode.innerHTML : '';
     196    },
    193197
    194198    get defaultView(){
    195199      return {
     
    314318
    315319  DOMElement.prototype = extend( new DOMNode(), {
    316320    get nodeName(){
    317       return this.tagName.toUpperCase();
     321      return String(this.tagName.toUpperCase());
    318322    },
    319323    get tagName(){
    320       return this._dom.getTagName();
     324      return String(this._dom.getTagName());
    321325    },
    322326    toString: function(){
    323327      return "<" + this.tagName + (this.id ? "#" + this.id : "" ) + ">";
     
    449453    get value() { return this.getAttribute("value") || ""; },
    450454    set value(val) { return this.setAttribute("value",val); },
    451455
    452     get src() { return this.getAttribute("src") || ""; },
     456    get href() {
     457      if (!this._dom.hasAttribute("href")) { return undefined; }
     458      return resolveUri(this, this.getAttribute("href"));
     459    },
     460    set href(val) { return this.setAttribute("href",val); },
     461
     462    get src() {
     463      if (!this._dom.hasAttribute("src")) { return undefined; }
     464      return resolveUri(this, this.getAttribute("src"));
     465    },
    453466    set src(val) { return this.setAttribute("src",val); },
    454467
    455468    get id() { return this.getAttribute("id") || ""; },
     
    457470
    458471    getAttribute: function(name){
    459472      return this._dom.hasAttribute(name) ?
    460         new String( this._dom.getAttribute(name) ) :
     473        String( this._dom.getAttribute(name) ) :
    461474        null;
    462475    },
    463476    setAttribute: function(name,value){
     
    550563    return a;
    551564  }
    552565
     566  /**
     567   * Resolves a relative uri to an absolute one in the context of
     568   * this document.
     569   * This will resolve relative to any <base> or document.location
     570   * as appropriate.
     571   */
     572  function resolveUri(node, uri) {
     573    var doc = node.ownerDocument;
     574    var bases = doc.getElementsByTagName("base");
     575    var baseUri = null;
     576    if ( bases.length && bases[0]._dom.hasAttribute("href") ) {
     577      // Don't access "href" property to avoid inf. recursion
     578      baseUri = bases[0].getAttribute("href");
     579    } else {
     580      baseUri = String(doc.location);
     581    }
     582    return String((new java.net.URI(baseUri)).resolve(uri));
     583  }
     584
    553585  // Helper method for generating the right
    554586  // DOM objects based upon the type
    555587