JavaScript object length difference

Why  does the object have a length of 6 and the object ↓has a length of 1? Is it somewhere in the spec? (Tested in Firefox, Chrome, and Safari.)

Jsfiddle

+4
source share
2 answers

I agree that this is a very strange behavior, but at least it is indicated.

The HTML fragment fragment serialization algorithm states that:

( ) "&" "&", "<" "<", " > " " > ", U + 00A0 NO-BREAK SPACE " " , , , "" "".

. , , , . DOM <div>&nbsp;&nbsp;</div> <div> </div>, DOM, *. , .

, &darr; .

, , .textContent, , .

* , , &nbsp; U+00A0, , , DOM

+8

HTML:

<div>
  <p>foo &amp; bar &#x1D306; baz</p>
</div>

innerHTML HTML Living, , , div.innerHTML HTML . , DOM Parsing, :

, node HTML-, HTML ; [...]

HTML HTML. div.innerHTML, , "if current node Element" 3.2. <p> .

node . "if current node Text node". :

[...] node s data IDL, , .

data IDL . :

( ) :

  • & &amp;.

  • U + 00A0 NO-BREAK SPACE &nbsp;.

  • , " &quot;.

  • , < &lt; > &gt;.

HTML .innerHTML - Unicode , , HTML.

- "&darr;" HTML "↓" innerHTML. , , "&amp;" "&#x26;" "&amp;", "&nbsp;" &#xA0; "&nbsp;".

0

All Articles