benjycui / benjycui/jsonml.js

isRaw is undefined when calling utils.appendChild

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12
Forks
7
PR merge metrics
No merged PRs in 30d

Description

Original comments: https://github.com/benjycui/jsonml.js/pull/5#discussion_r146114644

Calling `utils.appendChild` with a raw element throws an error.

```js
const html = require('jsonml.js/lib/html');
const utils = require('jsonml.js/lib/utils');

const jml = ['div']
const rawEl = html.raw('foo');
utils.appendChild(jml, rawEl); // TypeError: exports.isRaw is not a function
```

Indeed, `exports.isRaw` is not defined within `utils.js`. It _is_, however, defined within `html.js`. So, the fix should be fairly straightforward.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with lib/utils.js and inspect how appendChild handles raw elements, then compare its isRaw reference with the definition in lib/html.js. Reproduce the provided example using jsonml.js/lib/html and jsonml.js/lib/utils; the work is done when appending html.raw('foo') no longer throws the isRaw TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.