Blame view

lib/jsdom/living/nodes/HTMLBaseElement-impl.js 715 Bytes
858f2bdf5   Boyan Georgiev   fixes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  "use strict";
  const whatwgURL = require("whatwg-url");
  const HTMLElementImpl = require("./HTMLElement-impl").implementation;
  const { fallbackBaseURL } = require("../helpers/document-base-url");
  
  class HTMLBaseElementImpl extends HTMLElementImpl {
    get href() {
      const document = this._ownerDocument;
  
      const url = this.hasAttributeNS(null, "href") ? this.getAttributeNS(null, "href") : "";
      const parsed = whatwgURL.parseURL(url, { baseURL: fallbackBaseURL(document) });
  
      if (parsed === null) {
        return url;
      }
  
      return whatwgURL.serializeURL(parsed);
    }
  
    set href(value) {
      this.setAttributeNS(null, "href", value);
    }
  }
  
  module.exports = {
    implementation: HTMLBaseElementImpl
  };