Opened 10 years ago
Closed 10 years ago
#13367 closed defect (wontfix)
[regression] dojo.hasClass (dom/class.contains) crashed if passed DomNode is a Text node
Reported by: | cjolif | Owned by: | Eugene Lazutkin |
---|---|---|---|
Priority: | high | Milestone: | 1.7 |
Component: | HTML | Version: | 1.7.0b1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
See #13366 for a dojox.mobile sample that highlights this issue. Obviously a Text node can't have a class however we used to not crash in that case and I guess simply return false. I would say we should not create an compatibility here and keep previous behavior. This was recently introduced in [25723].
Note: See
TracTickets for help on using
tickets.
As a policy we don't provide extensive validation if input parameters, opting for GIGO and "fail early" approaches. Text nodes "worked" before not by design (as you can imagine) but by a pure luck --- they should not work with majority of our API including
dojo.byId()
, which is used universally. Given all that I suggest to implement text node checks in the user code locally, rather than increase our core codebase to cater for such rare event decreasing the overall performance in the process.