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

TypeError: Cannot set property parentNode of #<Node> which has only a getter #87

Open
hoIIer opened this issue Sep 11, 2021 · 0 comments

Comments

@hoIIer
Copy link

hoIIer commented Sep 11, 2021

In an ember fastboot.js app using jsdom I'm getting the following error when running the code snippet below:

TypeError: Cannot set property parentNode of #<Node> which has only a getter
    at removeBetween (/Users/eric/Projects/proj/proj/node_modules/@simple-dom/document/src/mutation.ts:65:22)
    at removeChild (/Users/eric/Projects/proj/proj/node_modules/@simple-dom/document/src/mutation.ts:17:3)
    at insertBetween (/Users/eric/Projects/proj/proj/node_modules/@simple-dom/document/src/mutation.ts:39:5)
    at insertBefore (/Users/eric/Projects/proj/proj/node_modules/@simple-dom/document/src/mutation.ts:7:3)
    at SimpleNodeImpl.insertBefore$1 [as insertBefore] (/Users/eric/Projects/proj/proj/node_modules/@simple-dom/document/dist/commonjs/es5/index.js:260:5)
    at NodeDOMTreeConstruction.insertBefore (/var/folders/9r/gp7xyl_j0l3flcwp78j7mjcr0000gn/T/broccoli-89288T7xicfBW5nOU/out-599-append_ember_auto_import_analyzer/assets/@glimmer/runtime.js:4283:1)
const { URL } = require('url');
const { JSDOM } = require('jsdom');

const { DOMParser } = new JSDOM().window;

module.exports = function() {
  return {
    buildSandboxGlobals(globals) {
      return {...globals, DOMParser, URL };
    },
  };
};

with app code:

import Component from '@glimmer/component';
import { textToHtml } from 'proj/utils/markup-text';

export default class MarkupTextComponent extends Component {
  debugName = 'markup-text';

  get nodes() {
    const markdown = textToHtml(this.args.text, this.args.options);
    const nodes = new DOMParser()
      .parseFromString(markdown, 'text/html')
      .body
      .childNodes;

    return Array.from(nodes);
  }
}
{{~#each this.nodes as |node|~}}{{~node~}}{{~/each~}}

Looking to see if anyone has any ideas on how to resolve?

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

1 participant