Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do nothing when pinObject is a nonexistent element #11

Closed

Conversation

HerringtonDarkholme
Copy link

Because Position normalizes pinObject (as in Position.pin's signature), its element will become a VIEWPORT plain object when pinObject contains a nonexistent element.
This would break the following CSS query in old IE(<=9) if the user is not meticulous enough.

However, passing empty jQuery object is quite pervasive, and it is even harder to preclude pernicious problems like this: $('<div id="must-exist">').appendTo('#yet-another-nonexistent'). jQuery creates a detached div but removes it then because no container is found. The final result is still an empty $ object.

In old IE, querying css property of empty jQuery will produce an exception that freezes all subsequent code in the same context, even if Position.pin is wrapped in try..catch.. block. In modern browsers this does not matter much but still halting futile code execution is preferred.

Position can be more care-free if the burden of validating element is placed not on users. I hope this patch can make it done.

I tried to write new test case in the specs but did not manage to set up the test environment. I only tested on my local project, I wish this revision will pass.

Best wishes

afc163 added a commit that referenced this pull request Jul 16, 2014
@afc163
Copy link
Member

afc163 commented Jul 16, 2014

Merged manually, Thx a lot!

@afc163 afc163 closed this Jul 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants