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

Issues in IE 11 #1756

Closed
wants to merge 1 commit into from
Closed

Issues in IE 11 #1756

wants to merge 1 commit into from

Conversation

ikorgik
Copy link

@ikorgik ikorgik commented Apr 4, 2018

Fixes for several issues in IE 11 we found during slate integration:

Objects are not valid as a React child (found: object with keys {size, _origin, _capacity, _level, _root, _tail, ownerID, hash, __altered}). If you meant to render a collection of children, use an array instead. in span (at text.js:130)
Unable to get property 'childNodes' of undefined or null reference
Objects are not valid as a React child (found: List [ [object Object] ]). If you meant to render a collection of children, use an array instead.

@ikorgik ikorgik changed the title Fixed issues in ie11 Issues in ie11 Apr 4, 2018
@ikorgik ikorgik changed the title Issues in ie11 Issues in IE 11 Apr 4, 2018
@ikorgik ikorgik mentioned this pull request Apr 4, 2018
@zhujinxuan
Copy link
Contributor

zhujinxuan commented Apr 4, 2018

A bit unrelated question: Have you tried babel-polyfill in building the web?

I remember there are several includes methods requiring babel-polyfill for IE in final build

@ikorgik
Copy link
Author

ikorgik commented Apr 4, 2018

Hi @zhujinxuan, didn't try it in this case, but use some other polyfills in my project like:
es6-shim, some packages from core-js (es7/array, symbol) and polyfill for closest

@bsouthga
Copy link
Contributor

bsouthga commented Apr 12, 2018

would be awesome to get this in, looks like the build error is just from prettier not liking a semicolon.

@bsouthga
Copy link
Contributor

for more context, we are seeing the same issues in IE 11 with default core-js

Copy link

@sethmcleod sethmcleod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a maintainer of this project, but I've made a few suggestions. Overall these changes look good!

@@ -327,8 +329,8 @@ class Html {
const { document } = value
const elements = document.nodes.map(this.serializeNode).filter(el => el)
if (options.render === false) return elements

const html = renderToStaticMarkup(<body>{elements}</body>)
// Converts List to Array to support IE 11.
Copy link

@sethmcleod sethmcleod Apr 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this and similar comments be updated to say COMPAT: Converts List to Array for IE11 support for consistency with other compatibility comments?

@@ -343,14 +345,17 @@ class Html {
serializeNode = node => {
if (node.object === 'text') {
const leaves = node.getLeaves()
return leaves.map(this.serializeLeaf)
const children = leaves.map(this.serializeLeaf);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this semicolon needs to be removed.

@@ -121,6 +121,8 @@ class Html {
*/

deserialize = (html, options = {}) => {
// Provides default value to make it working in IE 11.
Copy link

@sethmcleod sethmcleod Apr 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we update this comment to something along these lines: COMPAT: Provide a default value for IE11 support

@ianstormtaylor
Copy link
Owner

Hey @ikorgik, thank you for this. Could you make the changes to the comments to append COMPAT: to them, to match the rest of the codebase.

For the serializer change, does it need to be '<p></p> or can it be just an empty string ''? I'd rather not force the paragraph default on folks to be hardcoded here.

@terenceodonoghue
Copy link

terenceodonoghue commented May 10, 2018

I'm hitting the same problem in IE11.

Unable to get property 'childNodes' of undefined or null reference

Is there an interim fix that I might be able to use in the meantime?

@enzoferey
Copy link
Contributor

enzoferey commented Jun 23, 2018

Hi, we are facing issues in IE11 as well. We are using the slate-html-serializer, which we could fix its incompatibility by having a default initial state of "<p></p>" instead of "". Regarding Slate itself, we have noticed that the placeholder prop was introducing errors. We will be working on fixing everything along next week and I will update you here based on our advancements. Have a nice weekend and thanks for this amazing library ! 🙌

@enzoferey
Copy link
Contributor

enzoferey commented Jul 2, 2018

One of my teammates reported me this:

"The problem is that IE11 lets users select placeholder text, which is disabled with css on other browsers.
By selecting I mean it should have pointer-events disabled"

Dunno if that is helpful for you in any way. I will take a look at it pretty soon anyways ;)

@danielsarin danielsarin mentioned this pull request Aug 16, 2018
4 tasks
@danielsarin
Copy link
Contributor

I think I managed to track down the Unable to get property 'childNodes' of undefined or null reference error and submitted a pull request. But for now you can also fix it by supplying the modified parser as a custom parseHtml to the serializer. Ex.

const parseHtml = (html) => {
  const parsed = new DOMParser().parseFromString(html, 'text/html')
  const { body } = parsed
  // COMPAT: in IE 11 body is null if html is an empty string
  return body || window.document.createElement('body')
}

const html = new Html({ rules, parseHtml });

ianstormtaylor pushed a commit that referenced this pull request Aug 16, 2018
#### Is this adding or improving a _feature_ or fixing a _bug_?

This should fix `Unable to get property 'childNodes' of undefined or null reference` error in IE11 when using slate-html-serializer and deserializing an empty string (#1757, #1756).

#### What's the new behavior?

The `defaultParseHtml` now returns an empty body element if the parsed body is null. 

I tested this in the latest Chrome, Firefox and Safari, and they all seemed to work similarly. If the html param was an empty string, `parseFromString` returned a document element, which had a body property which was an empty body element. In IE11 though the body property was null, which caused the undefined or null reference later.

#### Have you checked that...?

* [x] The new code matches the existing patterns and styles.
* [x] The tests pass with `yarn test`.
* [x] The linter passes with `yarn lint`. (Fix errors with `yarn prettier`.)
* [x] The relevant examples still work. (Run examples with `yarn watch`.)
jtadmor pushed a commit to jtadmor/slate that referenced this pull request Jan 22, 2019
#### Is this adding or improving a _feature_ or fixing a _bug_?

This should fix `Unable to get property 'childNodes' of undefined or null reference` error in IE11 when using slate-html-serializer and deserializing an empty string (ianstormtaylor#1757, ianstormtaylor#1756).

#### What's the new behavior?

The `defaultParseHtml` now returns an empty body element if the parsed body is null. 

I tested this in the latest Chrome, Firefox and Safari, and they all seemed to work similarly. If the html param was an empty string, `parseFromString` returned a document element, which had a body property which was an empty body element. In IE11 though the body property was null, which caused the undefined or null reference later.

#### Have you checked that...?

* [x] The new code matches the existing patterns and styles.
* [x] The tests pass with `yarn test`.
* [x] The linter passes with `yarn lint`. (Fix errors with `yarn prettier`.)
* [x] The relevant examples still work. (Run examples with `yarn watch`.)
@ianstormtaylor ianstormtaylor mentioned this pull request Nov 14, 2019
@ianstormtaylor
Copy link
Owner

As of #3093 (which was just merged), I believe this issue is no longer applicable, because a lot has changed. I'm going through and closing out any potential issues that are not out of date with the overhaul. Thanks for understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants