Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Uncaught TypeError: Cannot read property 'clientWidth' of undefined #988

Closed
tkn98 opened this issue Jan 22, 2015 · 3 comments
Closed

Uncaught TypeError: Cannot read property 'clientWidth' of undefined #988

tkn98 opened this issue Jan 22, 2015 · 3 comments

Comments

@tkn98
Copy link

tkn98 commented Jan 22, 2015

Given that

var fancybox = jQuery.fancybox;

by using

        fancybox.helpers.overlay.open();

on jQuery(document).read() with version 2.1.5 triggers a

Uncaught TypeError: Cannot read property 'clientWidth' of undefined

This error happens with jQuery 1.6.2.

With a vanilla setup it works: http://jsfiddle.net/chssppkn/1 (jQuery 1.6.2)

The error comes from this line: https://github.com/fancyapps/fancyBox/blob/master/source/jquery.fancybox.js#L650

                    rez.w = locked[0].clientWidth;

because locked[0] is undefined. The precondition check

                if (locked && locked.length) {

is not catching up the circumstance the site is able to inject as dependency for locked.

@fancyapps
Copy link
Owner

If I remember correctly, minimum jQuery version is 1.7.1.

@tkn98
Copy link
Author

tkn98 commented Jan 22, 2015

It's not about the jQuery version, tested it for this case. See as well this comment on 4e1c57f

(Don't you tick revision for each fix release?)

@tkn98
Copy link
Author

tkn98 commented Jan 22, 2015

If I download the ZIP package and use the files therein I have the error.

If I take the same versioned (but not same file) from http://fancyapps.com/fancybox/source/jquery.fancybox.js I don't have the error.

Using the sources from the website fixes this.

@tkn98 tkn98 closed this as completed Jan 22, 2015
@tkn98 tkn98 mentioned this issue Jan 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants