Bug Tracker

Modify

Ticket #7961 (closed bug: patchwelcome)

Opened 2 years ago

Last modified 2 years ago

$.fn.height or $.fn.width throw a TypeError Result of expression 'elem.document.body' [null] is not an object

Reported by: miowang@… Owned by: miowang@…
Priority: low Milestone: 1.next
Component: manipulation Version: 1.4.4
Keywords: Cc:
Blocking: Blocked by:

Description

in line 7151:

return elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
  elem.document.body[ "client" + name ];

if the elem.document.documentElement[ "client" + name ] is 0, this code will try to eval "elem.document.body[ "client" + name ] " and throw a type error

Change History

comment:1 follow-up: ↓ 2 Changed 2 years ago by jitter

  • Owner set to miowang@…
  • Status changed from new to pending
  • Component changed from unfiled to manipulation

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

Please submit a reduced test case, which reproduces the issue you are experiencing, on  http://jsfiddle.net. So that we can investigate this issue further.


 How to report bugs

comment:2 in reply to: ↑ 1 Changed 2 years ago by miowang@…

  • Status changed from pending to new

I know I should submit a test case, but as this exception only been thrown when window's width is 0, and in most condition, it can't show on  http://jsfiddle.net/.

I found this issue is because my web app is visited by mobile device(like andorid), and sometimes the jquerymobile will try to invoke $(window).width() before the web view component is shown.

Replying to jitter:

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

Please submit a reduced test case, which reproduces the issue you are experiencing, on  http://jsfiddle.net. So that we can investigate this issue further.


 How to report bugs

comment:3 Changed 2 years ago by jitter

  • Priority changed from undecided to low
  • Status changed from new to closed
  • Resolution set to patchwelcome

So you are using jQuery mobile and not just jQuery core? Then maybe you should try and file this against the  jQuery-Mobile bug tracker because they might have more knowledge about WebView specific bugs.

Also without more specific information or some test case which reproduces (at least sometimes) the error debugging this is difficult/impossible.

Is this error triggered by some of your code (e.g. by not using a ready wrapper or stuff like that) or by jQuery-Mobile on its own?

Overall this sounds pretty strange, normally you would call .width() only after the page has finished loading (e.g. inside the ready wrapper) and at this point clientWidth should work.

Are you sure the elem.document.documentElement[ "client" + name ] part of the conditional is failing or is already elem.document.compatMode === "CSS1Compat" evaluating to false.


With the currently available information this issue can't be fixed. If you happen to be able to create a test which reproduces this and this is indeed a bug in jQuery which can be workaround please report back and we will happily reopen this ticket.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.