Skip to content

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

@erichaus

Description

@erichaus

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions