From 4010314ed257aeb09cfea9e24ed9e34731375245 Mon Sep 17 00:00:00 2001 From: Marin Ivanov Date: Wed, 21 Aug 2024 00:15:59 +0300 Subject: size optimisation --- ka.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'ka.js') diff --git a/ka.js b/ka.js index d2ae4bc..5dba500 100644 --- a/ka.js +++ b/ka.js @@ -1,8 +1,8 @@ -(()=>{ - doc = document; - entries = Object.entries; +doc = document; +let {entries,fromEntries} = Object; - var ep = Element.prototype; +(()=>{ + let ep = Element.prototype; ep.attr = function(name){ return this.getAttribute(name); }; @@ -25,15 +25,11 @@ this.onclick = callback; return this; } - const getvalue = x => x.value; - ep.$change2state = function(state, field, valgetter=getvalue) { + let getval = x => x.value; + ep.$change2state = function(state, field, getter=getval) { this.oninput = () => { this.setCustomValidity(''); - if (this.validity.valid) { - state[field] = valgetter(this); - } else { - this.reportValidity(); - } + this.validity.valid && (state[field] = getter(this)) || this.reportValidity(); }; return this; } -- cgit v1.2.3