I think the way to work cleanly with a DOM-rewriting library is to decide
which parts of your page you want Elm to control and which parts you want
JS to control.

You can use Elm.Main.embed to restrict your Elm program to only controlling
a part of the page. Or you could use Platform.program to run Elm
headlessly, with no view at all. Either way, you can use ports to
communicate with external JavaScript, which can in turn control the non-Elm
DOM.

There has also been some talk on the list about Polymer and Web
Components... maybe you can find a more satisfactory solution with those
tools. But I don't know anything about that.

On Mon, Dec 12, 2016 at 3:19 PM, <[email protected]> wrote:

> I posted this over on Stack Overflow
> <http://stackoverflow.com/questions/41111209/typeerror-domnode-is-undefined-and-other-errors-with-elm-and-3rd-party-js-lib>,
> but thought I would ask here too.
>
> I have been trying to use Elm applications to work with a handful of "UI
> Widget" type libraries. In particular I have been working with highlight.js
> and CodeMirror.
>
> This <https://ryanucode.github.io/elm-editor-demo/index.html> is a set of
> pared down code snippets from the project. The "Simple" example is just the
> raw elm app with no 3rd party libraries to show the expected result of the
> application. "Highligh JS" is a version showing errors working with the
> highlight.js library. Finally "CodeMirror" shows issues working with the
> CodeMirror library.
>
> The source code for the above examples can be found here
> <https://github.com/ryanucode/elm-editor-demo>. The pertinent files are
> /src/*.elm and docs/*.html
>
> The CodeMirror example gives the error from the title while the Highlight
> JS example results in a "corrupted" DOM.
>
> Many 3rd party JS libraries modify the DOM. How do you work with those
> libraries cleanly in Elm?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to