1--TEST--
2Element::removeAttribute()
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8echo "--- Remove after parsing ---\n";
9
10$dom = Dom\HTMLDocument::createFromString('<!DOCTYPE html><html><body align="foo" foo:bar="baz"></body></html>');
11$body = $dom->getElementsByTagName("body")[0];
12var_dump($body->removeAttribute("align"));
13var_dump($body->removeAttribute("foo:bar"));
14echo $dom->saveHtml($body), "\n";
15
16echo "--- Remove after creating without namespace ---\n";
17
18$body->setAttributeNode($attr = $dom->createAttribute("prefix:local"));
19$attr->value = "A";
20var_dump($body->removeAttribute("prefix:local"));
21echo $dom->saveHtml($body), "\n";
22
23echo "--- Remove after creating with namespace ---\n";
24
25$body->setAttributeNode($attr = $dom->createAttributeNS("urn:a", "prefix:local2"));
26$attr->value = "B";
27var_dump($body->removeAttribute("prefix:local2"));
28echo $dom->saveHtml($body), "\n";
29$body->setAttributeNode($attr = $dom->createAttributeNS("urn:a", "prefix:local2"));
30$attr->value = "B";
31var_dump($body->removeAttribute("Prefix:LOCAL2"));
32echo $dom->saveHtml($body), "\n";
33
34echo "--- Remove after creating with namespace case sensitive ---\n";
35
36$element = $dom->createElementNS("urn:a", "a:element");
37$attr = $dom->createAttributeNS("urn:a", "Prefix:local2");
38$element->setAttributeNode($attr);
39echo $dom->saveHtml($element), "\n";
40$attr->value = "C";
41var_dump($element->removeAttribute("Prefix:local2"));
42var_dump($element->removeAttribute("Prefix:LOCAL2"));
43var_dump($element->removeAttribute("prefix:local2"));
44echo $dom->saveHtml($element), "\n";
45
46?>
47--EXPECT--
48--- Remove after parsing ---
49NULL
50NULL
51<body></body>
52--- Remove after creating without namespace ---
53NULL
54<body></body>
55--- Remove after creating with namespace ---
56NULL
57<body></body>
58NULL
59<body></body>
60--- Remove after creating with namespace case sensitive ---
61<a:element Prefix:local2=""></a:element>
62NULL
63NULL
64NULL
65<a:element></a:element>
66