File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -64,14 +64,14 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
6464 < script >
6565 ( function cssVariablesUpdater ( ) {
6666 // Get the input elements from the DOM that we want to listen to
67- const inputsArray = Array . from ( document . querySelectorAll ( '.js-input' ) ) ;
67+ const inputs = document . querySelectorAll ( '.js-input' ) ;
6868 // Get root element
6969 const root = document . querySelector ( ':root' ) ;
7070 // Attach event listeners to listen for change
71- inputsArray . forEach ( ( input ) => {
71+ inputs . forEach ( ( input ) => {
7272 input . addEventListener ( 'input' , ( e ) => {
7373 // Check if a data-sizing attribute exists, if it does, set its value as the value of variable unit
74- const unit = e . target . attributes [ 'data-sizing' ] ? e . target . attributes [ 'data- sizing' ] . nodeValue : '' ;
74+ const unit = e . target . dataset . sizing || '' ;
7575 // Update the relevant css variable for the img
7676 root . style . setProperty ( `--${ e . target . name } ` , `${ e . target . value } ${ unit } ` ) ;
7777 } ) ;
You can’t perform that action at this time.
0 commit comments