Skip to content

Commit e83e763

Browse files
author
Rasool, Zeeshan (UK - London)
committed
tweaks based on new stuff learnt from wes
1 parent 0b6168a commit e83e763

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

03 - CSS Variables/index-MINE.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)