Last active
November 20, 2019 11:39
-
-
Save AirStair/9c24a23367fa0087c8b69d7a12c2edfa to your computer and use it in GitHub Desktop.
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
Document.prototype.transformProperty = function (selector, property, transformGetter, transformSetter) { | |
Object.defineProperty(document.querySelector(selector), property, { | |
get: function () { | |
return transformGetter(document.querySelector(selector).cloneNode()[property]); | |
}, | |
set: function (value) { | |
let clone = document.querySelector(selector).cloneNode(true); | |
clone.value = transformSetter(value); | |
document.querySelector(selector).replaceWith(clone); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment