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

Element.Position.setOffsetOption() may throw "offsetParent is null" #1088

Closed
RiZKiT opened this issue Jan 4, 2012 · 3 comments
Closed

Element.Position.setOffsetOption() may throw "offsetParent is null" #1088

RiZKiT opened this issue Jan 4, 2012 · 3 comments

Comments

@RiZKiT
Copy link
Contributor

RiZKiT commented Jan 4, 2012

setOffsetOption: function(element, options){
    var parentOffset = {x: 0, y: 0},
        offsetParent = element.measure(function(){
            return document.id(this.getOffsetParent());
        }),
        parentScroll = offsetParent.getScroll();

In some situations the last line will throw an offsetParent is null error. That comes when the result of the measure call is null, what happens when this.getOffsetParent() returns null. To mention, element is not null!

This should be fixed in on or another way, for example with if (offsetParent != null).

I had the problem when I used the newest clientcide version and StickyWin Modal. There is a masker which isn't visible and getOffsetParent() returns null.

@yannschepens
Copy link

We found the problem about this problem,

In the method setOffsetOption, the test about the existancy and the type of offsetParent is done after the call of the getScroll.

We modified as is

setOffsetOption: function(element, options) { 
  var parentOffset = {x: 0, y: 0},
  offsetParent = element.measure(function(){
    return document.id(this.getOffsetParent());
  }),
  //parentScroll = offsetParent.getScroll(); // From here
  if (!offsetParent || offsetParent == element.getDocument().body) return;
  // To here
  parentScroll = offsetParent.getScroll();

@RiZKiT
Copy link
Contributor Author

RiZKiT commented Apr 12, 2012

Thanx for the help, but first there is a local variable definition missing now, second I don't get an error now and the function silently returns, which makes the debugging even worse. I don't know if that is a good solution.

Maybe it's more a problem of the clientcide scripts.

@SergioCrisostomo
Copy link
Member

Merged by 08f564d

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

No branches or pull requests

3 participants