Problems with the new Html deserializer
See original GitHub issueDo you want to request a feature or report a bug?
A bug.
What’s the current behavior?
The new Html deserializer doesn’t work with the default parseHtml
function. You can see the errors trying to paste some html in the paste html example.
First you have this error:
Uncaught TypeError: _this.parseHtml is not a function
That could be resolved by passing explicitily null
to Html
constructor like this, but I think it should be fixed to also use the default parser if the options is undefined
:
const serializer = new Html({
rules: RULES,
parseHtml: null
});
Then I created this fiddle to show the next error: https://jsfiddle.net/6u1e543z/
Uncaught TypeError: elements.filter is not a function
This happen because elements
is a NodeList
, not an Array
so filter
is not defined there.
I don’t know if there are more, couldn’t get past this one.
What’s the expected behavior?
The Html should work as before after updating the deserialize methods.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:12 (3 by maintainers)
Top GitHub Comments
Here’s my html serializer rules
and this is the example I’m using
initializing the state with the Raw serializer works fine
For people arriving here one year later. I was running into the same issue in a tests environment with Docker + Karma + PhantomJS. PhantomJS didn’t have access to the DOMParser API so it would fail. I tried adding JSDOM.fragment as suggested in the docs but it wasn’t working. The workaround was to move away from PhantomJS to a jsdom environment throught https://github.com/badeball/karma-jsdom-launcher. No longer needed to specify a parseHtml prop and bye-bye to the deprecated PhantomJS !