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

Cannot use the same instance to render nested mobiledocs #11

Closed
gpoitch opened this issue Nov 10, 2015 · 0 comments
Closed

Cannot use the same instance to render nested mobiledocs #11

gpoitch opened this issue Nov 10, 2015 · 0 comments
Assignees

Comments

@gpoitch
Copy link
Member

gpoitch commented Nov 10, 2015

If you have a mobiledoc with a card that contains another mobiledoc, you cannot use the same renderer instance to render everything.

import MobiledocDomRenderer from 'mobiledoc-dom-renderer'

const renderer = new MobiledocDomRenderer.default()

const cards = {
  'some-card' : {},
  'some-other-card': {},
  'listicle-item-card': {
    display: { 
      setup: function (element, options, env, payload) {
        renderer.render(payload.mobiledoc, element, cards) // fixable by creating new MobiledocDomRenderer.default()
      }
    }
  }
}

const bodies = [{"version":"0.2.0","sections":[[],[[1,"p",[[[],0,"Opening text"]]]]]},{"version":"0.2.0","sections":[[],[[10,"listicle-item-card",{"title":"Item 1 title","primaryMedia":{},"mobiledoc":{"version":"0.2.0","sections":[[],[[1,"p",[[[],0,"Item 1 content"]]]]]}}]]]}]

renderer.render(bodies[1], null, cards) // => Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': The new child element contains the parent.

I also think the API would make more sense if you set your card definitions as part of the renderer constructor instead of passing them to the render method every time.

@bantic bantic self-assigned this Nov 13, 2015
bantic added a commit that referenced this issue Nov 13, 2015
bantic added a commit that referenced this issue Nov 13, 2015
bantic added a commit that referenced this issue Nov 16, 2015
bantic added a commit that referenced this issue Nov 16, 2015
@bantic bantic mentioned this issue Nov 16, 2015
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

2 participants