@@ -62,6 +62,9 @@ describe('DOMImplementation', () => {
6262 expect ( root . prefix ) . toBe ( null ) ;
6363 expect ( root . localName ) . toBe ( NAME ) ;
6464 expect ( doc . documentElement ) . toBe ( root ) ;
65+ expect ( doc . childElementCount ) . toBe ( 1 ) ;
66+ expect ( doc . firstElementChild ) . toBe ( root ) ;
67+ expect ( doc . lastElementChild ) . toBe ( root ) ;
6568 expect ( doc . contentType ) . toBe ( MIME_TYPE . XML_APPLICATION ) ;
6669 expect ( doc . type ) . toBe ( 'xml' ) ;
6770 } ) ;
@@ -80,6 +83,9 @@ describe('DOMImplementation', () => {
8083 expect ( root . tagName ) . toBe ( NAME ) ;
8184
8285 expect ( doc . documentElement ) . toBe ( root ) ;
86+ expect ( doc . childElementCount ) . toBe ( 1 ) ;
87+ expect ( doc . firstElementChild ) . toBe ( root ) ;
88+ expect ( doc . lastElementChild ) . toBe ( root ) ;
8389 expect ( doc . contentType ) . toBe ( MIME_TYPE . XML_APPLICATION ) ;
8490 expect ( doc . type ) . toBe ( 'xml' ) ;
8591 } ) ;
@@ -99,25 +105,9 @@ describe('DOMImplementation', () => {
99105 expect ( root . tagName ) . toBe ( qualifiedName ) ;
100106
101107 expect ( doc . documentElement ) . toBe ( root ) ;
102- expect ( doc . contentType ) . toBe ( MIME_TYPE . XML_APPLICATION ) ;
103- expect ( doc . type ) . toBe ( 'xml' ) ;
104- } ) ;
105-
106- test ( 'should create a Document with root element in a named namespace' , ( ) => {
107- const impl = new DOMImplementation ( ) ;
108- const qualifiedName = `${ PREFIX } :${ NAME } ` ;
109- const doc = impl . createDocument ( NS , qualifiedName ) ;
110-
111- const root = doc . childNodes . item ( 0 ) ;
112- expect ( root ) . toBeInstanceOf ( Element ) ;
113- expect ( root . ownerDocument ) . toBe ( doc ) ;
114- expect ( root . namespaceURI ) . toBe ( NS ) ;
115- expect ( root . prefix ) . toBe ( PREFIX ) ;
116- expect ( root . localName ) . toBe ( NAME ) ;
117- expect ( root . nodeName ) . toBe ( qualifiedName ) ;
118- expect ( root . tagName ) . toBe ( qualifiedName ) ;
119-
120- expect ( doc . documentElement ) . toBe ( root ) ;
108+ expect ( doc . childElementCount ) . toBe ( 1 ) ;
109+ expect ( doc . firstElementChild ) . toBe ( root ) ;
110+ expect ( doc . lastElementChild ) . toBe ( root ) ;
121111 expect ( doc . contentType ) . toBe ( MIME_TYPE . XML_APPLICATION ) ;
122112 expect ( doc . type ) . toBe ( 'xml' ) ;
123113 } ) ;
@@ -142,6 +132,9 @@ describe('DOMImplementation', () => {
142132 expect ( root . tagName ) . toBe ( qualifiedName ) ;
143133
144134 expect ( doc . documentElement ) . toBe ( root ) ;
135+ expect ( doc . childElementCount ) . toBe ( 1 ) ;
136+ expect ( doc . firstElementChild ) . toBe ( root ) ;
137+ expect ( doc . lastElementChild ) . toBe ( root ) ;
145138 expect ( doc . contentType ) . toBe ( MIME_TYPE . XML_APPLICATION ) ;
146139 expect ( doc . type ) . toBe ( 'xml' ) ;
147140 } ) ;
@@ -210,6 +203,9 @@ describe('DOMImplementation', () => {
210203 expect ( doc . doctype . ownerDocument ) . toBe ( doc ) ;
211204 expect ( doc . childNodes . item ( 0 ) ) . toBe ( doc . doctype ) ;
212205 expect ( doc . firstChild ) . toBe ( doc . doctype ) ;
206+ expect ( doc . childElementCount ) . toBe ( 1 ) ;
207+ expect ( doc . firstElementChild ) . toBe ( doc . documentElement ) ;
208+ expect ( doc . lastElementChild ) . toBe ( doc . documentElement ) ;
213209
214210 expect ( doc . documentElement ) . not . toBeNull ( ) ;
215211 expect ( doc . documentElement . localName ) . toBe ( 'html' ) ;
@@ -219,10 +215,14 @@ describe('DOMImplementation', () => {
219215 expect ( htmlNode . firstChild ) . not . toBeNull ( ) ;
220216 expect ( htmlNode . firstChild . nodeName ) . toBe ( 'head' ) ;
221217 expect ( htmlNode . firstChild . childNodes ) . toHaveLength ( 0 ) ;
218+ expect ( htmlNode . firstElementChild ) . toBe ( htmlNode . firstChild ) ;
219+ expect ( htmlNode . firstElementChild . nextElementSibling ) . toBe ( htmlNode . lastChild ) ;
222220
223221 expect ( htmlNode . lastChild ) . not . toBeNull ( ) ;
224222 expect ( htmlNode . lastChild . nodeName ) . toBe ( 'body' ) ;
225223 expect ( htmlNode . lastChild . childNodes ) . toHaveLength ( 0 ) ;
224+ expect ( htmlNode . lastElementChild ) . toBe ( htmlNode . lastChild ) ;
225+ expect ( htmlNode . lastElementChild . previousElementSibling ) . toBe ( htmlNode . firstChild ) ;
226226 } ) ;
227227 test ( 'should create an HTML document with specified elements including an empty title' , ( ) => {
228228 const impl = new DOMImplementation ( ) ;
0 commit comments