Created
September 28, 2023 02:15
-
-
Save gordonbrander/4a3f35565390b9edc1c56f7eef21b000 to your computer and use it in GitHub Desktop.
prop.js - make DOM fast with a write-through cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set property of element. | |
// Uses a write-through cache to only set | |
// when value actually changes. | |
export const prop = (el, key, value) => { | |
let cacheKey = Symbol.from(`prop.${key}`) | |
if (el[cacheKey] != value) { | |
el[cacheKey] = value | |
el[key] = value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment