@@ -166,61 +166,59 @@ class DocumentImpl extends NodeImpl {
166166 #namedPropertyCollections;
167167 #namedPropertyElementsCache = null ;
168168
169- constructor ( globalObject , args , privateData ) {
169+ constructor ( globalObject , args , {
170+ options : {
171+ parsingMode = "xml" ,
172+ encoding = "UTF-8" ,
173+ contentType = parsingMode === "xml" ? "application/xml" : "text/html" ,
174+ defaultView = null ,
175+ cookieJar = new CookieJar ( null , { looseMode : true } ) ,
176+ parseOptions,
177+ scriptingDisabled = false ,
178+ url : urlOption = "about:blank" ,
179+ parentOrigin,
180+ referrer = "" ,
181+ lastModified = new Date ( ) ,
182+ readyState = "complete"
183+ } = { } ,
184+ ...privateData
185+ } ) {
170186 super ( globalObject , args , privateData ) ;
171187
172188 this . _initGlobalEvents ( ) ;
173189
174190 this . _ownerDocument = this ;
175191 this . nodeType = NODE_TYPE . DOCUMENT_NODE ;
176- if ( ! privateData . options ) {
177- privateData . options = { } ;
178- }
179- if ( ! privateData . options . parsingMode ) {
180- privateData . options . parsingMode = "xml" ;
181- }
182- if ( ! privateData . options . encoding ) {
183- privateData . options . encoding = "UTF-8" ;
184- }
185- if ( ! privateData . options . contentType ) {
186- privateData . options . contentType = privateData . options . parsingMode === "xml" ? "application/xml" : "text/html" ;
187- }
188-
189- this . _parsingMode = privateData . options . parsingMode ;
192+ this . _parsingMode = parsingMode ;
190193
191194 this . _implementation = DOMImplementation . createImpl ( this . _globalObject , [ ] , {
192195 ownerDocument : this
193196 } ) ;
194197
195- this . _defaultView = privateData . options . defaultView || null ;
196- this . _global = privateData . options . global ;
198+ this . _defaultView = defaultView ;
197199 this . _byIdCache = new ByIdCache ( this ) ;
198200 this . _isInDocumentTree = true ;
199201 this . _currentScript = null ;
200202 this . _pageShowingFlag = false ;
201- this . _cookieJar = privateData . options . cookieJar ;
202- this . _parseOptions = privateData . options . parseOptions || { } ;
203- this . _scriptingDisabled = privateData . options . scriptingDisabled ;
204- if ( this . _cookieJar === undefined ) {
205- this . _cookieJar = new CookieJar ( null , { looseMode : true } ) ;
206- }
203+ this . _cookieJar = cookieJar ;
204+ this . _parseOptions = { ...parseOptions } ;
205+ this . _scriptingDisabled = scriptingDisabled ;
207206
208207 if ( this . _scriptingDisabled ) {
209208 this . _parseOptions . scriptingEnabled = false ;
210209 }
211210
212- this . contentType = privateData . options . contentType ;
213- this . _encoding = privateData . options . encoding ;
211+ this . contentType = contentType ;
212+ this . _encoding = encoding ;
214213
215- const urlOption = privateData . options . url === undefined ? "about:blank" : privateData . options . url ;
216214 const parsed = whatwgURL . parseURL ( urlOption ) ;
217215 if ( parsed === null ) {
218216 throw new TypeError ( `Could not parse "${ urlOption } " as a URL` ) ;
219217 }
220218
221219 this . _URL = parsed ;
222- this . _origin = urlOption === "about:blank" && privateData . options . parentOrigin ?
223- privateData . options . parentOrigin :
220+ this . _origin = urlOption === "about:blank" && parentOrigin ?
221+ parentOrigin :
224222 whatwgURL . serializeURLOrigin ( this . _URL ) ;
225223
226224 this . _location = Location . createImpl ( this . _globalObject , [ ] , { relevantDocument : this } ) ;
@@ -232,8 +230,8 @@ class DocumentImpl extends NodeImpl {
232230
233231 this . _workingNodeIterators = new IterableWeakSet ( ) ;
234232
235- this . _referrer = privateData . options . referrer || "" ;
236- this . _lastModified = toLastModifiedString ( privateData . options . lastModified || new Date ( ) ) ;
233+ this . _referrer = referrer ;
234+ this . _lastModified = toLastModifiedString ( lastModified ) ;
237235 this . _asyncQueue = new AsyncResourceQueue ( ) ;
238236 this . _queue = new ResourceQueue ( { asyncQueue : this . _asyncQueue , paused : false } ) ;
239237 this . _deferQueue = new ResourceQueue ( { paused : true } ) ;
@@ -244,7 +242,7 @@ class DocumentImpl extends NodeImpl {
244242 this . _isDestroyed = false ;
245243 this . _childDocuments = new Set ( ) ;
246244 this . _parentDocument = null ;
247- this . _currentDocumentReadiness = privateData . options . readyState || "complete" ;
245+ this . _currentDocumentReadiness = readyState ;
248246
249247 this . _lastFocusedElement = null ;
250248
0 commit comments