ember-fastboot / ember-fastboot/simple-dom

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

Open
#87 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
207
Forks
30
PR merge metrics
No merged PRs in 30d

Description

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 # 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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.