Opened 10 years ago
Closed 10 years ago
#12732 closed feature (duplicate)
hasAttr
Reported by: | markel | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | attributes | Version: | 1.8.2 |
Keywords: | 1.9-discuss | Cc: | |
Blocked by: | Blocking: |
Description
This is duplicate of #4324 and #9396. You already voted on #9396, deciding to say no, but i was told to bring this up again, when 1.9 will be around the corner.
To summarize –
Pros
- It's faster then jQuery#attr – http://jsperf.com/attr-vs-hasattr
- This is a commonly requested feature
- Because it's faster, it could be used inside jQuery or in jQuery plugin, for example – http://bugs.jquery.com/ticket/10463
- It would make good pair for jQuery#hasClass
- Use of jQuery#hasAttr is more clearer then though jQuery#attr method
Cons
- Yes it's faster, but in what real world application it could be a bottleneck?
- One more method to support and maintain
- Hit on size (75 bytes)
Change History (6)
comment:1 Changed 10 years ago by
Component: | unfiled → attributes |
---|---|
Keywords: | 1.9-discuss added |
Priority: | undecided → low |
Status: | new → open |
Version: | git → 1.8.2 |
comment:2 Changed 10 years ago by
comment:3 Changed 10 years ago by
In 2.0, the native .hasAttribute would work fine. However, if we want to make it "jQueryified", we could wrap it in hasAttr with an each. If we do that though, we should have the same, but cross-browser, API in 1.9. I'm fine either way.
comment:5 Changed 10 years ago by
i tried to make it as small as possible, i hope those 75 bytes would not be a deciding point in this.
Given that some edge-cases bugs take up to 40 bytes and all those gibson optimizations and future deprecated stuff that will be removed in 1.9 and a lot (a lot) of stuff that will be removed in 2.0 will give some perspective.
+0