* Get the value of the given property or attribute. If the "attribute" is for * a boolean property, we return null in the case where the value is false. If * the attribute name is "style" an attempt to convert that style into a string * is done. * * @param element The element to use. * @param
(element: Element, attribute: string)
| 26 | * @return The string value of the attribute or property, or null. |
| 27 | */ |
| 28 | function get(element: Element, attribute: string): string | null { |
| 29 | const PROPERTY_ALIASES: Record<string, string> = { |
| 30 | 'class': 'className', |
| 31 | 'readonly': 'readOnly', |
| 32 | }; |
| 33 | |
| 34 | const BOOLEAN_PROPERTIES: Set<string> = new Set([ |
| 35 | 'allowfullscreen', |
| 36 | 'allowpaymentrequest', |
| 37 | 'allowusermedia', |
| 38 | 'async', |
| 39 | 'autofocus', |
| 40 | 'autoplay', |
| 41 | 'checked', |
| 42 | 'compact', |
| 43 | 'complete', |
| 44 | 'controls', |
| 45 | 'declare', |
| 46 | 'default', |
| 47 | 'defaultchecked', |
| 48 | 'defaultselected', |
| 49 | 'defer', |
| 50 | 'disabled', |
| 51 | 'ended', |
| 52 | 'formnovalidate', |
| 53 | 'hidden', |
| 54 | 'indeterminate', |
| 55 | 'iscontenteditable', |
| 56 | 'ismap', |
| 57 | 'itemscope', |
| 58 | 'loop', |
| 59 | 'multiple', |
| 60 | 'muted', |
| 61 | 'nohref', |
| 62 | 'nomodule', |
| 63 | 'noresize', |
| 64 | 'noshade', |
| 65 | 'novalidate', |
| 66 | 'nowrap', |
| 67 | 'open', |
| 68 | 'paused', |
| 69 | 'playsinline', |
| 70 | 'pubdate', |
| 71 | 'readonly', |
| 72 | 'required', |
| 73 | 'reversed', |
| 74 | 'scoped', |
| 75 | 'seamless', |
| 76 | 'seeking', |
| 77 | 'selected', |
| 78 | 'truespeed', |
| 79 | 'typemustmatch', |
| 80 | 'willvalidate', |
| 81 | ]); |
| 82 | |
| 83 | function getAttribute(element: Element, attributeName: string): string | null { |
| 84 | return element.getAttribute(attributeName.toLowerCase()); |
| 85 | } |
nothing calls this directly
no test coverage detected