-
Notifications
You must be signed in to change notification settings - Fork 27.4k
attrs defining properties that are not existent in 1.4 #12370
Comments
Writing A more consistent way to check for whether an attribute is present or not, is Anyway, I think this issue has been fixed recently, so could you try if it still happens on 1.4.3 ? |
Sorry we also used ownproperty but thanks I will restest -----Original Message----- Writing if (attrs.myAttr) isn't enough, because it does an empty string still evaluates to false (i.e. the attribute may be present but you won't detect it using if (attrs.myAttr) if it has an empty value. |
IIRC this is fixed (at least marginally) in one of my recent prs, but I don't think it's landed yet. |
Thanks ! Will keep an eye out. -----Original Message----- if (attrs.hasOwnProperty('myAttr')) this isn't super good, because there are cases where the attribute is shadowed but uninitialized. You also want to tack a && attrs.myAttr !== void 0 test, for reliability. |
It used to work (without the |
yeah i'm pretty sure we never merged it |
#12290 still open and waiting |
I am gonna close this as a duplicate. I am pretty confident #12290 will land this or next week. |
our workaround right now is
PS: without es6 we would write |
in <=1.3 the directives attrs object only contained those attributes that are actually defined on an element. with 1.4 the attrs contains them even when they are not defined (seems to me it looks in scope or so, but havent looked into that).
previously we could write if(attrs.myAttr){} now we have to check for undefined.
The text was updated successfully, but these errors were encountered: