comparison vendor/masterminds/html5/src/HTML5/Elements.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 /** 2 /**
3 * Provide general element functions. 3 * Provide general element functions.
4 */ 4 */
5
5 namespace Masterminds\HTML5; 6 namespace Masterminds\HTML5;
6 7
7 /** 8 /**
8 * This class provides general information about HTML5 elements, 9 * This class provides general information about HTML5 elements,
9 * including syntactic and semantic issues. 10 * including syntactic and semantic issues.
15 * naming that this could significantly shrink the size and maybe make it 16 * naming that this could significantly shrink the size and maybe make it
16 * faster. See the Go teams implementation at https://code.google.com/p/go/source/browse/html/atom. 17 * faster. See the Go teams implementation at https://code.google.com/p/go/source/browse/html/atom.
17 */ 18 */
18 class Elements 19 class Elements
19 { 20 {
20
21 /** 21 /**
22 * Indicates an element is described in the specification. 22 * Indicates an element is described in the specification.
23 */ 23 */
24 const KNOWN_ELEMENT = 1; 24 const KNOWN_ELEMENT = 1;
25 25
75 * The HTML5 elements as defined in http://dev.w3.org/html5/markup/elements.html. 75 * The HTML5 elements as defined in http://dev.w3.org/html5/markup/elements.html.
76 * 76 *
77 * @var array 77 * @var array
78 */ 78 */
79 public static $html5 = array( 79 public static $html5 = array(
80 "a" => 1, 80 'a' => 1,
81 "abbr" => 1, 81 'abbr' => 1,
82 "address" => 65, // NORMAL | BLOCK_TAG 82 'address' => 65, // NORMAL | BLOCK_TAG
83 "area" => 9, // NORMAL | VOID_TAG 83 'area' => 9, // NORMAL | VOID_TAG
84 "article" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 84 'article' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
85 "aside" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 85 'aside' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
86 "audio" => 65, // NORMAL | BLOCK_TAG 86 'audio' => 1, // NORMAL
87 "b" => 1, 87 'b' => 1,
88 "base" => 9, // NORMAL | VOID_TAG 88 'base' => 9, // NORMAL | VOID_TAG
89 "bdi" => 1, 89 'bdi' => 1,
90 "bdo" => 1, 90 'bdo' => 1,
91 "blockquote" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 91 'blockquote' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
92 "body" => 1, 92 'body' => 1,
93 "br" => 9, // NORMAL | VOID_TAG 93 'br' => 9, // NORMAL | VOID_TAG
94 "button" => 1, 94 'button' => 1,
95 "canvas" => 65, // NORMAL | BLOCK_TAG 95 'canvas' => 65, // NORMAL | BLOCK_TAG
96 "caption" => 1, 96 'caption' => 1,
97 "cite" => 1, 97 'cite' => 1,
98 "code" => 1, 98 'code' => 1,
99 "col" => 9, // NORMAL | VOID_TAG 99 'col' => 9, // NORMAL | VOID_TAG
100 "colgroup" => 1, 100 'colgroup' => 1,
101 "command" => 9, // NORMAL | VOID_TAG 101 'command' => 9, // NORMAL | VOID_TAG
102 // "data" => 1, // This is highly experimental and only part of the whatwg spec (not w3c). See https://developer.mozilla.org/en-US/docs/HTML/Element/data 102 // "data" => 1, // This is highly experimental and only part of the whatwg spec (not w3c). See https://developer.mozilla.org/en-US/docs/HTML/Element/data
103 "datalist" => 1, 103 'datalist' => 1,
104 "dd" => 65, // NORMAL | BLOCK_TAG 104 'dd' => 65, // NORMAL | BLOCK_TAG
105 "del" => 1, 105 'del' => 1,
106 "details" => 17, // NORMAL | AUTOCLOSE_P, 106 'details' => 17, // NORMAL | AUTOCLOSE_P,
107 "dfn" => 1, 107 'dfn' => 1,
108 "dialog" => 17, // NORMAL | AUTOCLOSE_P, 108 'dialog' => 17, // NORMAL | AUTOCLOSE_P,
109 "div" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 109 'div' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
110 "dl" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 110 'dl' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
111 "dt" => 1, 111 'dt' => 1,
112 "em" => 1, 112 'em' => 1,
113 "embed" => 9, // NORMAL | VOID_TAG 113 'embed' => 9, // NORMAL | VOID_TAG
114 "fieldset" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 114 'fieldset' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
115 "figcaption" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 115 'figcaption' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
116 "figure" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 116 'figure' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
117 "footer" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 117 'footer' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
118 "form" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 118 'form' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
119 "h1" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 119 'h1' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
120 "h2" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 120 'h2' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
121 "h3" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 121 'h3' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
122 "h4" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 122 'h4' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
123 "h5" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 123 'h5' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
124 "h6" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 124 'h6' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
125 "head" => 1, 125 'head' => 1,
126 "header" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 126 'header' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
127 "hgroup" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 127 'hgroup' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
128 "hr" => 73, // NORMAL | VOID_TAG 128 'hr' => 73, // NORMAL | VOID_TAG
129 "html" => 1, 129 'html' => 1,
130 "i" => 1, 130 'i' => 1,
131 "iframe" => 3, // NORMAL | TEXT_RAW 131 'iframe' => 3, // NORMAL | TEXT_RAW
132 "img" => 9, // NORMAL | VOID_TAG 132 'img' => 9, // NORMAL | VOID_TAG
133 "input" => 9, // NORMAL | VOID_TAG 133 'input' => 9, // NORMAL | VOID_TAG
134 "kbd" => 1, 134 'kbd' => 1,
135 "ins" => 1, 135 'ins' => 1,
136 "keygen" => 9, // NORMAL | VOID_TAG 136 'keygen' => 9, // NORMAL | VOID_TAG
137 "label" => 1, 137 'label' => 1,
138 "legend" => 1, 138 'legend' => 1,
139 "li" => 1, 139 'li' => 1,
140 "link" => 9, // NORMAL | VOID_TAG 140 'link' => 9, // NORMAL | VOID_TAG
141 "map" => 1, 141 'map' => 1,
142 "mark" => 1, 142 'mark' => 1,
143 "menu" => 17, // NORMAL | AUTOCLOSE_P, 143 'menu' => 17, // NORMAL | AUTOCLOSE_P,
144 "meta" => 9, // NORMAL | VOID_TAG 144 'meta' => 9, // NORMAL | VOID_TAG
145 "meter" => 1, 145 'meter' => 1,
146 "nav" => 17, // NORMAL | AUTOCLOSE_P, 146 'nav' => 17, // NORMAL | AUTOCLOSE_P,
147 "noscript" => 65, // NORMAL | BLOCK_TAG 147 'noscript' => 65, // NORMAL | BLOCK_TAG
148 "object" => 1, 148 'object' => 1,
149 "ol" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 149 'ol' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
150 "optgroup" => 1, 150 'optgroup' => 1,
151 "option" => 1, 151 'option' => 1,
152 "output" => 65, // NORMAL | BLOCK_TAG 152 'output' => 65, // NORMAL | BLOCK_TAG
153 "p" => 209, // NORMAL | AUTOCLOSE_P | BLOCK_TAG | BLOCK_ONLY_INLINE 153 'p' => 209, // NORMAL | AUTOCLOSE_P | BLOCK_TAG | BLOCK_ONLY_INLINE
154 "param" => 9, // NORMAL | VOID_TAG 154 'param' => 9, // NORMAL | VOID_TAG
155 "pre" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 155 'pre' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
156 "progress" => 1, 156 'progress' => 1,
157 "q" => 1, 157 'q' => 1,
158 "rp" => 1, 158 'rp' => 1,
159 "rt" => 1, 159 'rt' => 1,
160 "ruby" => 1, 160 'ruby' => 1,
161 "s" => 1, 161 's' => 1,
162 "samp" => 1, 162 'samp' => 1,
163 "script" => 3, // NORMAL | TEXT_RAW 163 'script' => 3, // NORMAL | TEXT_RAW
164 "section" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 164 'section' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
165 "select" => 1, 165 'select' => 1,
166 "small" => 1, 166 'small' => 1,
167 "source" => 9, // NORMAL | VOID_TAG 167 'source' => 9, // NORMAL | VOID_TAG
168 "span" => 1, 168 'span' => 1,
169 "strong" => 1, 169 'strong' => 1,
170 "style" => 3, // NORMAL | TEXT_RAW 170 'style' => 3, // NORMAL | TEXT_RAW
171 "sub" => 1, 171 'sub' => 1,
172 "summary" => 17, // NORMAL | AUTOCLOSE_P, 172 'summary' => 17, // NORMAL | AUTOCLOSE_P,
173 "sup" => 1, 173 'sup' => 1,
174 "table" => 65, // NORMAL | BLOCK_TAG 174 'table' => 65, // NORMAL | BLOCK_TAG
175 "tbody" => 1, 175 'tbody' => 1,
176 "td" => 1, 176 'td' => 1,
177 "textarea" => 5, // NORMAL | TEXT_RCDATA 177 'textarea' => 5, // NORMAL | TEXT_RCDATA
178 "tfoot" => 65, // NORMAL | BLOCK_TAG 178 'tfoot' => 65, // NORMAL | BLOCK_TAG
179 "th" => 1, 179 'th' => 1,
180 "thead" => 1, 180 'thead' => 1,
181 "time" => 1, 181 'time' => 1,
182 "title" => 5, // NORMAL | TEXT_RCDATA 182 'title' => 5, // NORMAL | TEXT_RCDATA
183 "tr" => 1, 183 'tr' => 1,
184 "track" => 9, // NORMAL | VOID_TAG 184 'track' => 9, // NORMAL | VOID_TAG
185 "u" => 1, 185 'u' => 1,
186 "ul" => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG 186 'ul' => 81, // NORMAL | AUTOCLOSE_P | BLOCK_TAG
187 "var" => 1, 187 'var' => 1,
188 "video" => 65, // NORMAL | BLOCK_TAG 188 'video' => 65, // NORMAL | BLOCK_TAG
189 "wbr" => 9, // NORMAL | VOID_TAG 189 'wbr' => 9, // NORMAL | VOID_TAG
190 190
191 // Legacy? 191 // Legacy?
192 'basefont' => 8, // VOID_TAG 192 'basefont' => 8, // VOID_TAG
193 'bgsound' => 8, // VOID_TAG 193 'bgsound' => 8, // VOID_TAG
194 'noframes' => 2, // RAW_TEXT 194 'noframes' => 2, // RAW_TEXT
200 'plaintext' => 48, // AUTOCLOSE_P | TEXT_PLAINTEXT 200 'plaintext' => 48, // AUTOCLOSE_P | TEXT_PLAINTEXT
201 'applet' => 0, 201 'applet' => 0,
202 'marquee' => 0, 202 'marquee' => 0,
203 'isindex' => 8, // VOID_TAG 203 'isindex' => 8, // VOID_TAG
204 'xmp' => 20, // AUTOCLOSE_P | VOID_TAG | RAW_TEXT 204 'xmp' => 20, // AUTOCLOSE_P | VOID_TAG | RAW_TEXT
205 'noembed' => 2 // RAW_TEXT 205 'noembed' => 2, // RAW_TEXT
206 ); 206 );
207 207
208 /** 208 /**
209 * The MathML elements. 209 * The MathML elements.
210 * See http://www.w3.org/wiki/MathML/Elements. 210 * See http://www.w3.org/wiki/MathML/Elements.
213 * MathML. There is a nice list of this subset at https://developer.mozilla.org/en-US/docs/MathML/Element. 213 * MathML. There is a nice list of this subset at https://developer.mozilla.org/en-US/docs/MathML/Element.
214 * 214 *
215 * @var array 215 * @var array
216 */ 216 */
217 public static $mathml = array( 217 public static $mathml = array(
218 "maction" => 1, 218 'maction' => 1,
219 "maligngroup" => 1, 219 'maligngroup' => 1,
220 "malignmark" => 1, 220 'malignmark' => 1,
221 "math" => 1, 221 'math' => 1,
222 "menclose" => 1, 222 'menclose' => 1,
223 "merror" => 1, 223 'merror' => 1,
224 "mfenced" => 1, 224 'mfenced' => 1,
225 "mfrac" => 1, 225 'mfrac' => 1,
226 "mglyph" => 1, 226 'mglyph' => 1,
227 "mi" => 1, 227 'mi' => 1,
228 "mlabeledtr" => 1, 228 'mlabeledtr' => 1,
229 "mlongdiv" => 1, 229 'mlongdiv' => 1,
230 "mmultiscripts" => 1, 230 'mmultiscripts' => 1,
231 "mn" => 1, 231 'mn' => 1,
232 "mo" => 1, 232 'mo' => 1,
233 "mover" => 1, 233 'mover' => 1,
234 "mpadded" => 1, 234 'mpadded' => 1,
235 "mphantom" => 1, 235 'mphantom' => 1,
236 "mroot" => 1, 236 'mroot' => 1,
237 "mrow" => 1, 237 'mrow' => 1,
238 "ms" => 1, 238 'ms' => 1,
239 "mscarries" => 1, 239 'mscarries' => 1,
240 "mscarry" => 1, 240 'mscarry' => 1,
241 "msgroup" => 1, 241 'msgroup' => 1,
242 "msline" => 1, 242 'msline' => 1,
243 "mspace" => 1, 243 'mspace' => 1,
244 "msqrt" => 1, 244 'msqrt' => 1,
245 "msrow" => 1, 245 'msrow' => 1,
246 "mstack" => 1, 246 'mstack' => 1,
247 "mstyle" => 1, 247 'mstyle' => 1,
248 "msub" => 1, 248 'msub' => 1,
249 "msup" => 1, 249 'msup' => 1,
250 "msubsup" => 1, 250 'msubsup' => 1,
251 "mtable" => 1, 251 'mtable' => 1,
252 "mtd" => 1, 252 'mtd' => 1,
253 "mtext" => 1, 253 'mtext' => 1,
254 "mtr" => 1, 254 'mtr' => 1,
255 "munder" => 1, 255 'munder' => 1,
256 "munderover" => 1 256 'munderover' => 1,
257 ); 257 );
258 258
259 /** 259 /**
260 * The svg elements. 260 * The svg elements.
261 * 261 *
267 * While they are in the spec I'm not sure how widely implemented they are. 267 * While they are in the spec I'm not sure how widely implemented they are.
268 * 268 *
269 * @var array 269 * @var array
270 */ 270 */
271 public static $svg = array( 271 public static $svg = array(
272 "a" => 1, 272 'a' => 1,
273 "altGlyph" => 1, 273 'altGlyph' => 1,
274 "altGlyphDef" => 1, 274 'altGlyphDef' => 1,
275 "altGlyphItem" => 1, 275 'altGlyphItem' => 1,
276 "animate" => 1, 276 'animate' => 1,
277 "animateColor" => 1, 277 'animateColor' => 1,
278 "animateMotion" => 1, 278 'animateMotion' => 1,
279 "animateTransform" => 1, 279 'animateTransform' => 1,
280 "circle" => 1, 280 'circle' => 1,
281 "clipPath" => 1, 281 'clipPath' => 1,
282 "color-profile" => 1, 282 'color-profile' => 1,
283 "cursor" => 1, 283 'cursor' => 1,
284 "defs" => 1, 284 'defs' => 1,
285 "desc" => 1, 285 'desc' => 1,
286 "ellipse" => 1, 286 'ellipse' => 1,
287 "feBlend" => 1, 287 'feBlend' => 1,
288 "feColorMatrix" => 1, 288 'feColorMatrix' => 1,
289 "feComponentTransfer" => 1, 289 'feComponentTransfer' => 1,
290 "feComposite" => 1, 290 'feComposite' => 1,
291 "feConvolveMatrix" => 1, 291 'feConvolveMatrix' => 1,
292 "feDiffuseLighting" => 1, 292 'feDiffuseLighting' => 1,
293 "feDisplacementMap" => 1, 293 'feDisplacementMap' => 1,
294 "feDistantLight" => 1, 294 'feDistantLight' => 1,
295 "feFlood" => 1, 295 'feFlood' => 1,
296 "feFuncA" => 1, 296 'feFuncA' => 1,
297 "feFuncB" => 1, 297 'feFuncB' => 1,
298 "feFuncG" => 1, 298 'feFuncG' => 1,
299 "feFuncR" => 1, 299 'feFuncR' => 1,
300 "feGaussianBlur" => 1, 300 'feGaussianBlur' => 1,
301 "feImage" => 1, 301 'feImage' => 1,
302 "feMerge" => 1, 302 'feMerge' => 1,
303 "feMergeNode" => 1, 303 'feMergeNode' => 1,
304 "feMorphology" => 1, 304 'feMorphology' => 1,
305 "feOffset" => 1, 305 'feOffset' => 1,
306 "fePointLight" => 1, 306 'fePointLight' => 1,
307 "feSpecularLighting" => 1, 307 'feSpecularLighting' => 1,
308 "feSpotLight" => 1, 308 'feSpotLight' => 1,
309 "feTile" => 1, 309 'feTile' => 1,
310 "feTurbulence" => 1, 310 'feTurbulence' => 1,
311 "filter" => 1, 311 'filter' => 1,
312 "font" => 1, 312 'font' => 1,
313 "font-face" => 1, 313 'font-face' => 1,
314 "font-face-format" => 1, 314 'font-face-format' => 1,
315 "font-face-name" => 1, 315 'font-face-name' => 1,
316 "font-face-src" => 1, 316 'font-face-src' => 1,
317 "font-face-uri" => 1, 317 'font-face-uri' => 1,
318 "foreignObject" => 1, 318 'foreignObject' => 1,
319 "g" => 1, 319 'g' => 1,
320 "glyph" => 1, 320 'glyph' => 1,
321 "glyphRef" => 1, 321 'glyphRef' => 1,
322 "hkern" => 1, 322 'hkern' => 1,
323 "image" => 1, 323 'image' => 1,
324 "line" => 1, 324 'line' => 1,
325 "linearGradient" => 1, 325 'linearGradient' => 1,
326 "marker" => 1, 326 'marker' => 1,
327 "mask" => 1, 327 'mask' => 1,
328 "metadata" => 1, 328 'metadata' => 1,
329 "missing-glyph" => 1, 329 'missing-glyph' => 1,
330 "mpath" => 1, 330 'mpath' => 1,
331 "path" => 1, 331 'path' => 1,
332 "pattern" => 1, 332 'pattern' => 1,
333 "polygon" => 1, 333 'polygon' => 1,
334 "polyline" => 1, 334 'polyline' => 1,
335 "radialGradient" => 1, 335 'radialGradient' => 1,
336 "rect" => 1, 336 'rect' => 1,
337 "script" => 3, // NORMAL | RAW_TEXT 337 'script' => 3, // NORMAL | RAW_TEXT
338 "set" => 1, 338 'set' => 1,
339 "stop" => 1, 339 'stop' => 1,
340 "style" => 3, // NORMAL | RAW_TEXT 340 'style' => 3, // NORMAL | RAW_TEXT
341 "svg" => 1, 341 'svg' => 1,
342 "switch" => 1, 342 'switch' => 1,
343 "symbol" => 1, 343 'symbol' => 1,
344 "text" => 1, 344 'text' => 1,
345 "textPath" => 1, 345 'textPath' => 1,
346 "title" => 1, 346 'title' => 1,
347 "tref" => 1, 347 'tref' => 1,
348 "tspan" => 1, 348 'tspan' => 1,
349 "use" => 1, 349 'use' => 1,
350 "view" => 1, 350 'view' => 1,
351 "vkern" => 1 351 'vkern' => 1,
352 ); 352 );
353 353
354 /** 354 /**
355 * Some attributes in SVG are case sensetitive. 355 * Some attributes in SVG are case sensitive.
356 * 356 *
357 * This map contains key/value pairs with the key as the lowercase attribute 357 * This map contains key/value pairs with the key as the lowercase attribute
358 * name and the value with the correct casing. 358 * name and the value with the correct casing.
359 */ 359 */
360 public static $svgCaseSensitiveAttributeMap = array( 360 public static $svgCaseSensitiveAttributeMap = array(
417 'textlength' => 'textLength', 417 'textlength' => 'textLength',
418 'viewbox' => 'viewBox', 418 'viewbox' => 'viewBox',
419 'viewtarget' => 'viewTarget', 419 'viewtarget' => 'viewTarget',
420 'xchannelselector' => 'xChannelSelector', 420 'xchannelselector' => 'xChannelSelector',
421 'ychannelselector' => 'yChannelSelector', 421 'ychannelselector' => 'yChannelSelector',
422 'zoomandpan' => 'zoomAndPan' 422 'zoomandpan' => 'zoomAndPan',
423 ); 423 );
424 424
425 /** 425 /**
426 * Some SVG elements are case sensetitive. 426 * Some SVG elements are case sensitive.
427 * This map contains these. 427 * This map contains these.
428 * 428 *
429 * The map contains key/value store of the name is lowercase as the keys and 429 * The map contains key/value store of the name is lowercase as the keys and
430 * the correct casing as the value. 430 * the correct casing as the value.
431 */ 431 */
463 'feturbulence' => 'feTurbulence', 463 'feturbulence' => 'feTurbulence',
464 'foreignobject' => 'foreignObject', 464 'foreignobject' => 'foreignObject',
465 'glyphref' => 'glyphRef', 465 'glyphref' => 'glyphRef',
466 'lineargradient' => 'linearGradient', 466 'lineargradient' => 'linearGradient',
467 'radialgradient' => 'radialGradient', 467 'radialgradient' => 'radialGradient',
468 'textpath' => 'textPath' 468 'textpath' => 'textPath',
469 ); 469 );
470 470
471 /** 471 /**
472 * Check whether the given element meets the given criterion. 472 * Check whether the given element meets the given criterion.
473 * 473 *
475 * 475 *
476 * Elements::isA('script', Elements::TEXT_RAW); // Returns true. 476 * Elements::isA('script', Elements::TEXT_RAW); // Returns true.
477 * 477 *
478 * Elements::isA('script', Elements::TEXT_RCDATA); // Returns false. 478 * Elements::isA('script', Elements::TEXT_RCDATA); // Returns false.
479 * 479 *
480 * @param string $name 480 * @param string $name The element name.
481 * The element name. 481 * @param int $mask One of the constants on this class.
482 * @param int $mask 482 *
483 * One of the constants on this class. 483 * @return bool true if the element matches the mask, false otherwise.
484 * @return boolean true if the element matches the mask, false otherwise.
485 */ 484 */
486 public static function isA($name, $mask) 485 public static function isA($name, $mask)
487 { 486 {
488 if (! static::isElement($name)) { 487 return (static::element($name) & $mask) === $mask;
489 return false;
490 }
491
492 return (static::element($name) & $mask) == $mask;
493 } 488 }
494 489
495 /** 490 /**
496 * Test if an element is a valid html5 element. 491 * Test if an element is a valid html5 element.
497 * 492 *
498 * @param string $name 493 * @param string $name The name of the element.
499 * The name of the element. 494 *
500 * 495 * @return bool true if a html5 element and false otherwise.
501 * @return bool True if a html5 element and false otherwise.
502 */ 496 */
503 public static function isHtml5Element($name) 497 public static function isHtml5Element($name)
504 { 498 {
505 // html5 element names are case insensetitive. Forcing lowercase for the check. 499 // html5 element names are case insensitive. Forcing lowercase for the check.
506 // Do we need this check or will all data passed here already be lowercase? 500 // Do we need this check or will all data passed here already be lowercase?
507 return isset(static::$html5[strtolower($name)]); 501 return isset(static::$html5[strtolower($name)]);
508 } 502 }
509 503
510 /** 504 /**
511 * Test if an element name is a valid MathML presentation element. 505 * Test if an element name is a valid MathML presentation element.
512 * 506 *
513 * @param string $name 507 * @param string $name The name of the element.
514 * The name of the element. 508 *
515 * 509 * @return bool true if a MathML name and false otherwise.
516 * @return bool True if a MathML name and false otherwise.
517 */ 510 */
518 public static function isMathMLElement($name) 511 public static function isMathMLElement($name)
519 { 512 {
520 // MathML is case-sensetitive unlike html5 elements. 513 // MathML is case-sensitive unlike html5 elements.
521 return isset(static::$mathml[$name]); 514 return isset(static::$mathml[$name]);
522 } 515 }
523 516
524 /** 517 /**
525 * Test if an element is a valid SVG element. 518 * Test if an element is a valid SVG element.
526 * 519 *
527 * @param string $name 520 * @param string $name The name of the element.
528 * The name of the element. 521 *
529 * 522 * @return bool true if a SVG element and false otherise.
530 * @return boolean True if a SVG element and false otherise.
531 */ 523 */
532 public static function isSvgElement($name) 524 public static function isSvgElement($name)
533 { 525 {
534 // SVG is case-sensetitive unlike html5 elements. 526 // SVG is case-sensitive unlike html5 elements.
535 return isset(static::$svg[$name]); 527 return isset(static::$svg[$name]);
536 } 528 }
537 529
538 /** 530 /**
539 * Is an element name valid in an html5 document. 531 * Is an element name valid in an html5 document.
540 *
541 * This includes html5 elements along with other allowed embedded content 532 * This includes html5 elements along with other allowed embedded content
542 * such as svg and mathml. 533 * such as svg and mathml.
543 * 534 *
544 * @param string $name 535 * @param string $name The name of the element.
545 * The name of the element. 536 *
546 * 537 * @return bool true if valid and false otherwise.
547 * @return bool True if valid and false otherwise.
548 */ 538 */
549 public static function isElement($name) 539 public static function isElement($name)
550 { 540 {
551 return static::isHtml5Element($name) || static::isMathMLElement($name) || static::isSvgElement($name); 541 return static::isHtml5Element($name) || static::isMathMLElement($name) || static::isSvgElement($name);
552 } 542 }
553 543
554 /** 544 /**
555 * Get the element mask for the given element name. 545 * Get the element mask for the given element name.
556 * 546 *
557 * @param string $name 547 * @param string $name The name of the element.
558 * The name of the element. 548 *
559 * 549 * @return int the element mask.
560 * @return int|bool The element mask or false if element does not exist.
561 */ 550 */
562 public static function element($name) 551 public static function element($name)
563 { 552 {
564 if (isset(static::$html5[$name])) { 553 if (isset(static::$html5[$name])) {
565 return static::$html5[$name]; 554 return static::$html5[$name];
569 } 558 }
570 if (isset(static::$mathml[$name])) { 559 if (isset(static::$mathml[$name])) {
571 return static::$mathml[$name]; 560 return static::$mathml[$name];
572 } 561 }
573 562
574 return false; 563 return 0;
575 } 564 }
576 565
577 /** 566 /**
578 * Normalize a SVG element name to its proper case and form. 567 * Normalize a SVG element name to its proper case and form.
579 * 568 *
580 * @param string $name 569 * @param string $name The name of the element.
581 * The name of the element. 570 *
582 * 571 * @return string the normalized form of the element name.
583 * @return string The normalized form of the element name.
584 */ 572 */
585 public static function normalizeSvgElement($name) 573 public static function normalizeSvgElement($name)
586 { 574 {
587 $name = strtolower($name); 575 $name = strtolower($name);
588 if (isset(static::$svgCaseSensitiveElementMap[$name])) { 576 if (isset(static::$svgCaseSensitiveElementMap[$name])) {
593 } 581 }
594 582
595 /** 583 /**
596 * Normalize a SVG attribute name to its proper case and form. 584 * Normalize a SVG attribute name to its proper case and form.
597 * 585 *
598 * @param string $name 586 * @param string $name The name of the attribute.
599 * The name of the attribute.
600 * 587 *
601 * @return string The normalized form of the attribute name. 588 * @return string The normalized form of the attribute name.
602 */ 589 */
603 public static function normalizeSvgAttribute($name) 590 public static function normalizeSvgAttribute($name)
604 { 591 {
610 return $name; 597 return $name;
611 } 598 }
612 599
613 /** 600 /**
614 * Normalize a MathML attribute name to its proper case and form. 601 * Normalize a MathML attribute name to its proper case and form.
615 *
616 * Note, all MathML element names are lowercase. 602 * Note, all MathML element names are lowercase.
617 * 603 *
618 * @param string $name 604 * @param string $name The name of the attribute.
619 * The name of the attribute.
620 * 605 *
621 * @return string The normalized form of the attribute name. 606 * @return string The normalized form of the attribute name.
622 */ 607 */
623 public static function normalizeMathMlAttribute($name) 608 public static function normalizeMathMlAttribute($name)
624 { 609 {
625 $name = strtolower($name); 610 $name = strtolower($name);
626 611
627 // Only one attribute has a mixed case form for MathML. 612 // Only one attribute has a mixed case form for MathML.
628 if ($name == 'definitionurl') { 613 if ('definitionurl' === $name) {
629 $name = 'definitionURL'; 614 $name = 'definitionURL';
630 } 615 }
631 616
632 return $name; 617 return $name;
633 } 618 }