Sha256: 98dacf3553964ba0aeafef9fac6fce901c7de6f4375c5b24a71fedcea582141a

Contents?: true

Size: 1.33 KB

Versions: 26

Compression:

Stored size: 1.33 KB

Contents

"use strict";

const NodeListImpl = require("./NodeList-impl").implementation;

class RadioNodeListImpl extends NodeListImpl {
  // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-radionodelist-value
  // Note in general the spec says to manipulate/consult checkedness, but we use `checked` instead
  // because the spec isn't very good here: https://github.com/whatwg/html/issues/7612.

  get value() {
    this._update();

    const element = this._list.find(e => e._localName === "input" && e.type === "radio" && e.checked);
    if (element === undefined) {
      return "";
    }

    if (!element.hasAttributeNS(null, "value")) {
      return "on";
    }

    return element.getAttributeNS(null, "value");
  }

  set value(value) {
    let element;
    if (value === "on") {
      element = this._list.find(
        e => e._localName === "input" &&
             e.type === "radio" &&
             (!e.hasAttributeNS(null, "value") || e.getAttributeNS(null, "value") === value)
      );
    } else {
      element = this._list.find(
        e => e._localName === "input" &&
             e.type === "radio" &&
             (e.hasAttributeNS(null, "value") && e.getAttributeNS(null, "value") === value)
      );
    }

    if (element) {
      element.checked = true;
    }
  }
}

module.exports = {
  implementation: RadioNodeListImpl
};

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/jsdom/lib/jsdom/living/nodes/RadioNodeList-impl.js