* Converts a comma-separated data attribute string into an array of values. If * the string is empty, returns an empty array. If the string is not defined, * returns null.
(script, attributeName)
| 60833 | * returns null. |
| 60834 | */ |
| 60835 | function getPluginsOrPresetsFromScript(script, attributeName) { |
| 60836 | var rawValue = script.getAttribute(attributeName); |
| 60837 | if (rawValue === '') { |
| 60838 | // Empty string means to not load ANY presets or plugins |
| 60839 | return []; |
| 60840 | } |
| 60841 | if (!rawValue) { |
| 60842 | // Any other falsy value (null, undefined) means we're not overriding this |
| 60843 | // setting, and should use the default. |
| 60844 | return null; |
| 60845 | } |
| 60846 | return rawValue.split(',').map(function (item) { |
| 60847 | return item.trim(); |
| 60848 | }); |
| 60849 | } |
| 60850 | |
| 60851 | /** |
| 60852 | * Loop over provided script tags and get the content, via innerHTML if an |