Opened 10 years ago
Closed 10 years ago
#13666 closed bug (wontfix)
.text(null) sets text to 'null'
Reported by: | Owned by: | Rick Waldron | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
> $.fn.jquery "1.9.1" > $('<div>').text(null) [<div>null</div>] > $('<div>').text(undefined) [<div></div>]
I think 2nd case should return same as the 3d.
Change History (9)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Owner: | set to Rick Waldron |
---|---|
Status: | new → assigned |
Confirmed.
I'm concerned about breaking existing code, but I can't imagine why any code would ever rely on this. Before I fix it, I want to hear from dmethvin
comment:3 Changed 10 years ago by
under 1.7 both .text(undefined) & .text(null) works as getters.
1.7 it works the same as in example
) |
and also .html(null) works like .html()
comment:4 follow-up: 7 Changed 10 years ago by
Looks like we genuinely forgot about this specific case.
comment:5 Changed 10 years ago by
sorry about previous comment)
under 1.7 both .text(undefined) & .text(null) work as getters.
in jq >=1.7 it works the same as in example
I think think this behaviour just can reduce the code: .text(val) instead of .text(val)
and also .html(null) works like .html("")
comment:7 Changed 10 years ago by
Replying to jaubourg:
Looks like we genuinely forgot about this specific case.
I'd further clarify that by saying that null
and undefined
have never been documented as valid input, though they were de facto getters before the fix for #5571 landed in 1.7.2. We currently no-op on the latter (explicitly correct) and set on the former (since it is invalid input, this behavior is our prerogative).
comment:8 Changed 10 years ago by
To make it extra clear, .text(null)
and .text(undefined)
were not even setters until 1.7.2, though .text(undefined)
now explicitly no-ops.
comment:9 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
Closing as wont-fix, based on the information presented by gibson042
null
is not a valid argument to text()
http://jsfiddle.net/5FEfE/