diff --git a/language-snippets.ent b/language-snippets.ent index 26bb4819a0ed..4399e8d6db31 100644 --- a/language-snippets.ent +++ b/language-snippets.ent @@ -1677,6 +1677,27 @@ it is inserted with (e.g.) DOMNo resulting HTML. '> + + + + Throws a ValueError if + a token contains any null bytes. + + + + + Throws a Dom\DOMException with code + Dom\SYNTAX_ERR if a token is the empty string. + + + + + Throws a Dom\DOMException with code + Dom\INVALID_CHARACTER_ERR if a token contains any + ASCII whitespace. + + +'> diff --git a/reference/dom/dom/dom-tokenlist.xml b/reference/dom/dom/dom-tokenlist.xml index 7668819d3291..e44f44a4c6e0 100644 --- a/reference/dom/dom/dom-tokenlist.xml +++ b/reference/dom/dom/dom-tokenlist.xml @@ -45,13 +45,9 @@ &Methods; - Not documented yet - + @@ -76,10 +72,15 @@
&reftitle.notes; &dom.note.modern.utf8; + + + Tokens in the list can be accessed by array syntax. + +
- + &reference.dom.dom.entities.tokenlist; diff --git a/reference/dom/dom/tokenlist/add.xml b/reference/dom/dom/tokenlist/add.xml new file mode 100644 index 000000000000..e9c3e4634219 --- /dev/null +++ b/reference/dom/dom/tokenlist/add.xml @@ -0,0 +1,94 @@ + + + + Dom\TokenList::add + Adds the given tokens to the list + + + + &reftitle.description; + + public voidDom\TokenList::add + stringtokens + + + Adds the given tokens to the list, but not any that + were already present. + + + + + &reftitle.parameters; + + + tokens + + + The tokens to add. + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.errors; + &dom.tokenlist.errors; + + + + &reftitle.examples; + + <methodname>Dom\TokenList::add</methodname> example + + Adds two classes to a newly created paragraph element. + + +createElement('p'); + +$classList = $p->classList; +$classList->add('font-bold', 'important'); + +echo $dom->saveHtml($p); +?> +]]> + + &example.outputs; + +

+]]> +
+
+
+
+ diff --git a/reference/dom/dom/tokenlist/contains.xml b/reference/dom/dom/tokenlist/contains.xml new file mode 100644 index 000000000000..113e2a15487c --- /dev/null +++ b/reference/dom/dom/tokenlist/contains.xml @@ -0,0 +1,91 @@ + + + + Dom\TokenList::contains + Returns whether the list contains a given token + + + + &reftitle.description; + + public boolDom\TokenList::contains + stringtoken + + + Returns whether the list contains token. + + + + + &reftitle.parameters; + + + token + + + The token. + + + + + + + + &reftitle.returnvalues; + + Returns &true; if the list contains token, + &false; otherwise. + + + + + &reftitle.examples; + + <methodname>Dom\TokenList::contains</methodname> example + + Checks whether two classes are present on the paragraph. + + +

', LIBXML_NOERROR); +$p = $dom->body->firstChild; + +$classList = $p->classList; +var_dump( + $classList->contains('important'), + $classList->contains('font-small'), +); +?> +]]> +
+ &example.outputs; + + + +
+
+
+ diff --git a/reference/dom/dom/tokenlist/count.xml b/reference/dom/dom/tokenlist/count.xml new file mode 100644 index 000000000000..44a863ead9c5 --- /dev/null +++ b/reference/dom/dom/tokenlist/count.xml @@ -0,0 +1,50 @@ + + + + Dom\TokenList::count + Returns the number of tokens in the list + + + + &reftitle.description; + + public intDom\TokenList::count + + + + Returns the number of tokens in the list. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + The number of tokens in the list. + + + + diff --git a/reference/dom/dom/tokenlist/getiterator.xml b/reference/dom/dom/tokenlist/getiterator.xml new file mode 100644 index 000000000000..2f8fc464edc5 --- /dev/null +++ b/reference/dom/dom/tokenlist/getiterator.xml @@ -0,0 +1,50 @@ + + + + Dom\TokenList::getIterator + Returns an iterator over the token list + + + + &reftitle.description; + + public IteratorDom\TokenList::getIterator + + + + Returns an iterator over the token list. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + An iterator over the token list. + + + + diff --git a/reference/dom/dom/tokenlist/item.xml b/reference/dom/dom/tokenlist/item.xml new file mode 100644 index 000000000000..1c6f7d9cae03 --- /dev/null +++ b/reference/dom/dom/tokenlist/item.xml @@ -0,0 +1,100 @@ + + + + Dom\TokenList::item + Returns a token from the list + + + + &reftitle.description; + + public stringnullDom\TokenList::item + intindex + + + Returns a token from the list at index. + + + + + &reftitle.parameters; + + + index + + + The token index. + + + + + + + + &reftitle.returnvalues; + + Returns the token at index or &null; when the index + is out of bounds. + + + + + &reftitle.examples; + + <methodname>Dom\TokenList::item</methodname> example + + Accesses a valid index and an invalid index. + + +

', LIBXML_NOERROR); +$p = $dom->body->firstChild; + +$classList = $p->classList; +var_dump( + $classList->item(0), + $classList->item(100), +); +?> +]]> +
+ &example.outputs; + + + +
+
+ + + &reftitle.notes; + + + This method is equivalent to using array access syntax. + + + +
+ diff --git a/reference/dom/dom/tokenlist/remove.xml b/reference/dom/dom/tokenlist/remove.xml new file mode 100644 index 000000000000..85218f85968e --- /dev/null +++ b/reference/dom/dom/tokenlist/remove.xml @@ -0,0 +1,93 @@ + + + + Dom\TokenList::remove + Removes the given tokens from the list + + + + &reftitle.description; + + public voidDom\TokenList::remove + stringtokens + + + Removes the given tokens from the list, but ignores + any that were not present. + + + + + &reftitle.parameters; + + + tokens + + + The tokens to remove. + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.errors; + &dom.tokenlist.errors; + + + + &reftitle.examples; + + <methodname>Dom\TokenList::remove</methodname> example + + Removes two classes from the paragraph. + + +

', LIBXML_NOERROR); +$p = $dom->body->firstChild; + +$p->classList->remove('font-bold', 'important'); + +echo $dom->saveHtml($p); +?> +]]> +
+ &example.outputs; + +

+]]> +
+
+
+
+ diff --git a/reference/dom/dom/tokenlist/replace.xml b/reference/dom/dom/tokenlist/replace.xml new file mode 100644 index 000000000000..bf499c038d81 --- /dev/null +++ b/reference/dom/dom/tokenlist/replace.xml @@ -0,0 +1,102 @@ + + + + Dom\TokenList::replace + Replaces a token in the list with another one + + + + &reftitle.description; + + public boolDom\TokenList::replace + stringtoken + stringnewToken + + + Replaces a token in the list with another one. + + + + + &reftitle.parameters; + + + token + + + The token to replace. + + + + + newToken + + + The new token. + + + + + + + + &reftitle.returnvalues; + + Returns &true; if token was in the list, + &false; otherwise. + + + + + &reftitle.errors; + &dom.tokenlist.errors; + + + + &reftitle.examples; + + <methodname>Dom\TokenList::replace</methodname> example + + Replaces a token in the paragraph with another one. + + +

', LIBXML_NOERROR); +$p = $dom->body->firstChild; + +$p->classList->replace('font-bold', 'font-small'); + +echo $dom->saveHtml($p); +?> +]]> +
+ &example.outputs; + +

+]]> +
+
+
+
+ diff --git a/reference/dom/dom/tokenlist/supports.xml b/reference/dom/dom/tokenlist/supports.xml new file mode 100644 index 000000000000..8f9888c172d8 --- /dev/null +++ b/reference/dom/dom/tokenlist/supports.xml @@ -0,0 +1,68 @@ + + + + Dom\TokenList::supports + Returns whether the given token is supported + + + + &reftitle.description; + + public boolDom\TokenList::supports + stringtoken + + + Returns whether token is in the + associated attribute's supported tokens. + + + + + &reftitle.parameters; + + + token + + + The token. + + + + + + + + &reftitle.returnvalues; + + &return.success; + + + + + &reftitle.errors; + + Throws a TypeError when the attribute does + not define a supported tokens list. + + + + diff --git a/reference/dom/dom/tokenlist/toggle.xml b/reference/dom/dom/tokenlist/toggle.xml new file mode 100644 index 000000000000..e878092f9132 --- /dev/null +++ b/reference/dom/dom/tokenlist/toggle.xml @@ -0,0 +1,105 @@ + + + + Dom\TokenList::toggle + Toggles the presence of a token in the list + + + + &reftitle.description; + + public boolDom\TokenList::toggle + stringtoken + boolnullforce&null; + + + Toggles the presence of token in the list. + + + + + &reftitle.parameters; + + + token + + + The token to toggle. + + + + + force + + + If force is provided, setting it to &true; will + add the token, and setting it to &false; will remove the token. + + + + + + + + &reftitle.returnvalues; + + Returns &true; if the token is in the list after the call, + &false; otherwise. + + + + + &reftitle.errors; + &dom.tokenlist.errors; + + + + &reftitle.examples; + + <methodname>Dom\TokenList::toggle</methodname> example + + Toggles three classes, two without force, and one with. + + +

', LIBXML_NOERROR); +$p = $dom->body->firstChild; + +$classList = $p->classList; +$classList->toggle('font-bold', 'font-small'); +$classList->toggle('important', force: true); + +echo $dom->saveHtml($p); +?> +]]> +
+ &example.outputs; + +

+]]> +
+
+
+
+ diff --git a/reference/dom/versions.xml b/reference/dom/versions.xml index 514f4b0e865f..48fbb5681529 100644 --- a/reference/dom/versions.xml +++ b/reference/dom/versions.xml @@ -255,6 +255,16 @@ + + + + + + + + + +