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

Use explicit constructor in Draggable to fix IE10 null reference #158

Merged
merged 1 commit into from
May 19, 2016

Conversation

davidstubbs
Copy link
Contributor

There's a problem in IE10 with ES2015 classes and the super class.
Essentially the prototype isn't set up correctly which leads to
this.props being null when setting up position in the construction.

However, props are passed to the class constructor explicitly by React,
so we can use them from there.

Tested by running the examples in IE 10 on Win 7.

This is basically the same problem as addressed in #145, but fixed to work rather than just not blow up (and for version 2 props).

There's a problem in IE10 with ES2015 classes and the super class.
Essentially the prototype isn't set up correctly which leads to
this.props being null when setting up position in the construction.

However, props are passed to the class constructor explicitly by React,
so we can use them from there.

Tested by running the examples in IE 10 on Win 7.
@STRML
Copy link
Collaborator

STRML commented May 19, 2016

So it appears class property assignments are broken in Babel with IE < 11?

@davidstubbs
Copy link
Contributor Author

No, it's more that accessing properties placed on the object by the super constructor is broken.

this.props works no better in the explicit constructor than in a class property.

For example, writing this for Draggable:

 constructor(props) {
  super(props);
  console.log(this.props);
 }

On chrome: Object { zIndex: 100, children: Object ... }
On IE10: undefined

As I understand it there's a basic incompatibility between IE <= 10 and babel ES2015 classes because you can't set the prototype properly. There's a bunch of work arounds but they all have edge cases and side effects.

Using the explicit constructor just gives us independent access to the props as part of the published React API.

@STRML
Copy link
Collaborator

STRML commented May 19, 2016

👍 Thanks for the further information. It's a shame this bug exists, and I appreciate you taking the time to fix it.

@STRML STRML merged commit 041bec6 into react-grid-layout:master May 19, 2016
@STRML
Copy link
Collaborator

STRML commented May 19, 2016

Published in v2.0.1.

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