@@ -30,10 +30,8 @@ class Page {
3030 return this . _frame . contentWindow . localStorage ;
3131 }
3232
33- layout ( target = null ) {
34- // If target is provided, it should be a body element to force layout on
35- // Otherwise force layout on the current page's body
36- const body = target || this . _frame ?. contentDocument ?. body || document . body ;
33+ layout ( ) {
34+ const body = this . _frame ? this . _frame . contentDocument . body : document . body ;
3735
3836 const value = forceLayout ( body , params . layoutMode ) ;
3937 body . _leakedLayoutValue = value ; // Prevent dead code elimination.
@@ -73,7 +71,7 @@ class Page {
7371
7472 if ( element === null )
7573 return null ;
76- return this . wrapElement ( element ) ;
74+ return this . _wrapElement ( element ) ;
7775 }
7876
7977 /**
@@ -95,15 +93,15 @@ class Page {
9593 const lookupStartNode = this . _frame . contentDocument ;
9694 const elements = Array . from ( getParent ( lookupStartNode , path ) . querySelectorAll ( selector ) ) ;
9795 for ( let i = 0 ; i < elements . length ; i ++ )
98- elements [ i ] = this . wrapElement ( elements [ i ] ) ;
96+ elements [ i ] = this . _wrapElement ( elements [ i ] ) ;
9997 return elements ;
10098 }
10199
102100 getElementById ( id ) {
103101 const element = this . _frame . contentDocument . getElementById ( id ) ;
104102 if ( element === null )
105103 return null ;
106- return this . wrapElement ( element ) ;
104+ return this . _wrapElement ( element ) ;
107105 }
108106
109107 call ( functionName ) {
@@ -118,14 +116,14 @@ class Page {
118116 }
119117
120118 callToGetElement ( functionName ) {
121- return this . wrapElement ( this . _frame . contentWindow [ functionName ] ( ) ) ;
119+ return this . _wrapElement ( this . _frame . contentWindow [ functionName ] ( ) ) ;
122120 }
123121
124122 setWidth ( widthPx ) {
125123 this . _frame . style . width = `${ widthPx } px` ;
126124 }
127125
128- wrapElement ( element ) {
126+ _wrapElement ( element ) {
129127 return new PageElement ( element ) ;
130128 }
131129
@@ -146,14 +144,6 @@ class PageElement {
146144 this . #node = node ;
147145 }
148146
149- getContentDocument ( ) {
150- if ( this . #node. nodeName ?. toLowerCase ( ) !== "iframe" )
151- throw new Error ( "getContentDocument() called on non-iframe element" ) ;
152- if ( ! this . #node. contentDocument )
153- throw new Error ( "Iframe contentDocument is not available." ) ;
154- return this . #node. contentDocument ;
155- }
156-
157147 setValue ( value ) {
158148 this . #node. value = value ;
159149 }
0 commit comments