- From: Mathias Bynens <notifications@github.com>
- Date: Wed, 08 Jun 2022 02:53:59 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/pull/1079/review/999449047@github.com>
@mathiasbynens commented on this pull request. > + + <li><p>Return true. +</ol> + +<p class=note>This concept is used to validate [=/element=] [=Element/local names=], when +constructed by DOM APIs. The intention is to allow any name that is possible to construct using the +HTML parser (the branch where the first [=code point=] is an [=ASCII alpha=]), plus some additional +possibilities. For those additional possibilities, the ASCII range is restricted for historical +reasons, but beyond ASCII anything is allowed. + +<div class=note> + <p>The following JavaScript-compatible regular expression is an implementation of the above + definition: + + <pre class=lang-javascript> + /^(?:[A-Za-z][^\0\t\n\f\r\u0020/>]*)|(?:[:_\u0080-][A-Za-z-.:_\u0080-]*)$/u I think JavaScript doesn’t support character class ranges without the end of the range being explicit, so I’d change both occurrences of `[\u0080-]` into `[\x80-\u{10FFFF}]`. Is `[A-Za-z-.:_\u0080-]` meant to refer to step 4? In that case, it’s missing “ASCII digits”. Suggestion: `[A-Za-z0-9-.:_\x80-\u{10FFFF}]`. - Valid namespace prefix: `[\0\t\n\f\r />]` - Valid attribute local name: `[\0\t\n\f\r /=>]` - Valid element local name, step 2.1: `[^\0\t\n\f\r />]` - Valid element local name, step 3: `[:_\x80-\u{10FFFF}]` - Valid element local name, step 4: `[A-Za-z0-9-.:_\x80-\u{10FFFF}]` Piecing things together: ```js /^(?:[A-Za-z][^\0\t\n\f\r\x20/>]*)|(?:[:_\x80-\u{10FFFF}][A-Za-z0-9-.:_\x80-\u{10FFFF}]*)$/u ``` -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/pull/1079#discussion_r892159848 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/pull/1079/review/999449047@github.com>
Received on Wednesday, 8 June 2022 09:54:11 UTC