happy-dom icon indicating copy to clipboard operation
happy-dom copied to clipboard

innerHTML and outterHTML case that differs from browser behavior

Open weibangtuo opened this issue 7 months ago • 0 comments

Code

test('mytest', () => {
  const div = document.createElement('div')

  div.innerText = '<b>a</b>'
  expect(div.innerHTML).toBe('&lt;b&gt;a&lt;/b&gt;')
  expect(div.outerHTML).toBe('<div>&lt;b&gt;a&lt;/b&gt;</div>')
})

Expected behavior In a typical browser environment, this test case should pass. But it didn't.

AssertionError: expected '<b>a</b>' to be '&lt;b&gt;a&lt;/b&gt;' // Object.is equality

- Expected
+ Received

- &lt;b&gt;a&lt;/b&gt;
+ <b>a</b>

Device happy-dom version: 14.12.3

weibangtuo avatar Jul 23 '24 10:07 weibangtuo