Element-hasAttribute.html (860B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Element.prototype.hasAttribute</title> 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-hasattribute"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <span data-e2="2" data-F2="3" id="t"></span> 9 10 <script> 11 "use strict"; 12 13 test(() => { 14 15 const el = document.createElement("p"); 16 el.setAttributeNS("foo", "x", "first"); 17 18 assert_true(el.hasAttribute("x")); 19 20 }, "hasAttribute should check for attribute presence, irrespective of namespace"); 21 22 test(() => { 23 24 const el = document.getElementById("t"); 25 26 assert_true(el.hasAttribute("data-e2")); 27 assert_true(el.hasAttribute("data-E2")); 28 assert_true(el.hasAttribute("data-f2")); 29 assert_true(el.hasAttribute("data-F2")); 30 31 }, "hasAttribute should work with all attribute casings"); 32 </script>