fregante / delegate-it

DOM event delegation, in <1KB

Home Page:https://npmjs.com/delegate-it

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about `if` statement in `editLedger` method

ambujsahu81 opened this issue · comments

In the following code on line 39 , it seems that ledger.has(baseElement) will always be true. Since on line 37 base element was added to ledger. And hence it makes the whole expression (!wanted && !ledger.has(baseElement)) to be always false.

It seems that the if statement might not be required ?

delegate-it/index.ts

Lines 37 to 41 in e412983

ledger.set(baseElement, elementMap);
if (!wanted && !ledger.has(baseElement)) {
return false;
}

Thank you for the review! Indeed I think it was a mistake in 9624053

I'm not sure if the intent has always been to check the existence in the elements map rather than directly in the ledger. But yeah until now that line is always false and probably just a mistaken copy-paste.