syntax-tree/hast-util-raw

word in a raw node value getting duplicated

MoLow opened this issue · 4 comments

MoLow commented

Initial checklist

Affected packages and versions

hast-util-raw 7.2.1

Link to runnable example

https://stackblitz.com/edit/node-h5dh1f?file=index.js

Steps to reproduce

this was discovered in node.js docs, see nodejs/node#43864
provided a minimal repro in stackblitz where the last word in this case is repeated

Expected behavior

the output of

import { raw } from 'hast-util-raw';

const children = [
  { type: 'raw', value: 'this is a thing' },
  { type: 'raw', value: '<sup>' },
  { type: 'text', value: 'b' },
  { type: 'raw', value: '</sup>' },
];

console.log(raw({ type: 'root', children }));

should be

{
  type: 'root',
  children: [
    { type: 'text', value: 'this is a thing' },
    {
      type: 'element',
      tagName: 'sup',
      properties: {},
      children: [Array]
    }
  ],
  data: { quirksMode: false }
}

Actual behavior

the word thing is duplicated (changing to another word will result with the same issue):

{
  type: 'root',
  children: [
    { type: 'text', value: 'this is a thingthing' },
    {
      type: 'element',
      tagName: 'sup',
      properties: {},
      children: [Array]
    }
  ],
  data: { quirksMode: false }
}

Affected runtime and version

node18, node 16

Affected package manager and version

npm@8.11.0

Affected OS and version

any

Build and bundle tools

No response

Thanks, found it!

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

MoLow commented

Thanks!