tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Element-setAttribute.html (1166B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Element.prototype.setAttribute</title>
      4 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-setattribute">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 
      8 <script>
      9 "use strict";
     10 
     11 test(() => {
     12 
     13  const el = document.createElement("p");
     14  el.setAttributeNS("foo", "x", "first");
     15  el.setAttributeNS("foo2", "x", "second");
     16 
     17  el.setAttribute("x", "changed");
     18 
     19  assert_equals(el.attributes.length, 2);
     20  assert_equals(el.getAttribute("x"), "changed");
     21  assert_equals(el.getAttributeNS("foo", "x"), "changed");
     22  assert_equals(el.getAttributeNS("foo2", "x"), "second");
     23 
     24 }, "setAttribute should change the first attribute, irrespective of namespace");
     25 
     26 test(() => {
     27  // https://github.com/whatwg/dom/issues/31
     28 
     29  const el = document.createElement("p");
     30  el.setAttribute("FOO", "bar");
     31 
     32  assert_equals(el.getAttribute("foo"), "bar");
     33  assert_equals(el.getAttribute("FOO"), "bar");
     34  assert_equals(el.getAttributeNS("", "foo"), "bar");
     35  assert_equals(el.getAttributeNS("", "FOO"), null);
     36 
     37 }, "setAttribute should lowercase before setting");
     38 </script>