Side navigation
#11962 closed bug (fixed)
Opened June 23, 2012 12:15PM UTC
Closed July 10, 2012 03:11AM UTC
Standardize getter return values for empty sets.
Reported by: | cowboy | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.8 |
Component: | attributes | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Just like getter-setter detection logic has been standardized on arguments
, it might be a good idea for empty-set getters to always return a consistent value. I vote for null
.
I also understand if .text()
must continue to behave differently, because it's already a special case in other ways, and we need ''something'' to laugh at ironically.
$.fn.jquery // "1.7.2" $().attr("x") // undefined $().prop("x") // undefined $().css("x") // undefined $().val() // undefined $().text() // "" $().html() // null $().offset() // null
Please don't do this in a patch release, though! <3 (zing)
Attachments (0)
Change History (3)
Changed June 23, 2012 12:25PM UTC by comment:1
description: | Just like getter-setter detection logic has been standardized on `arguments`, it might be a good idea for empty-set getters to always return a consistent value. I vote for `null`. \ \ I also understand if `.text()` must continue to behave differently, because it's already a special case in other ways, and we need ''something'' to laugh at ironically. \ \ {{{ \ $.fn.jquery // "1.7.2" \ $().attr("x") // undefined \ $().prop("x") // undefined \ $().css("x") // undefined \ $().val() // undefined \ $().text() // "" \ $().html() // null \ $().offset() // null \ }}} \ \ Please don't do this in a patch release, though! <3 → Just like getter-setter detection logic has been standardized on `arguments`, it might be a good idea for empty-set getters to always return a consistent value. I vote for `null`. \ \ I also understand if `.text()` must continue to behave differently, because it's already a special case in other ways, and we need ''something'' to laugh at ironically. \ \ {{{ \ $.fn.jquery // "1.7.2" \ $().attr("x") // undefined \ $().prop("x") // undefined \ $().css("x") // undefined \ $().val() // undefined \ $().text() // "" \ $().html() // null \ $().offset() // null \ }}} \ \ Please don't do this in a patch release, though! <3 (zing) |
---|---|
summary: | Standardize getter return values on empty set. → Standardize getter return values for empty sets. |
Changed July 03, 2012 05:28PM UTC by comment:2
component: | unfiled → attributes |
---|---|
milestone: | None → 1.8 |
priority: | undecided → low |
status: | new → open |
I'd prefer undefined
since that changes fewer cases and avoids the Object
-ness of null
. Neither .html
nor .offset
have documented returns for empty sets so it should be safe to change. No way we're messing with .text
buddy. :)