@@ -239,8 +239,10 @@ class URL {
239239 constructor ( input , base ) {
240240 // toUSVString is not needed.
241241 input = `${ input } ` ;
242- if ( base !== undefined && ! ( base instanceof URL ) )
242+ if ( base !== undefined &&
243+ ( ! base [ searchParams ] || ! base [ searchParams ] [ searchParams ] ) ) {
243244 base = new URL ( base ) ;
245+ }
244246 parse ( this , input , base ) ;
245247 }
246248
@@ -885,7 +887,7 @@ class URLSearchParams {
885887 }
886888
887889 [ util . inspect . custom ] ( recurseTimes , ctx ) {
888- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
890+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
889891 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
890892 }
891893
@@ -947,7 +949,7 @@ function merge(out, start, mid, end, lBuffer, rBuffer) {
947949
948950defineIDLClass ( URLSearchParams . prototype , 'URLSearchParams' , {
949951 append ( name , value ) {
950- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
952+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
951953 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
952954 }
953955 if ( arguments . length < 2 ) {
@@ -961,7 +963,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
961963 } ,
962964
963965 delete ( name ) {
964- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
966+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
965967 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
966968 }
967969 if ( arguments . length < 1 ) {
@@ -982,7 +984,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
982984 } ,
983985
984986 get ( name ) {
985- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
987+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
986988 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
987989 }
988990 if ( arguments . length < 1 ) {
@@ -1000,7 +1002,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
10001002 } ,
10011003
10021004 getAll ( name ) {
1003- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1005+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
10041006 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
10051007 }
10061008 if ( arguments . length < 1 ) {
@@ -1019,7 +1021,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
10191021 } ,
10201022
10211023 has ( name ) {
1022- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1024+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
10231025 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
10241026 }
10251027 if ( arguments . length < 1 ) {
@@ -1037,7 +1039,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
10371039 } ,
10381040
10391041 set ( name , value ) {
1040- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1042+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
10411043 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
10421044 }
10431045 if ( arguments . length < 2 ) {
@@ -1125,15 +1127,15 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
11251127 // Define entries here rather than [Symbol.iterator] as the function name
11261128 // must be set to `entries`.
11271129 entries ( ) {
1128- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1130+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11291131 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11301132 }
11311133
11321134 return createSearchParamsIterator ( this , 'key+value' ) ;
11331135 } ,
11341136
11351137 forEach ( callback , thisArg = undefined ) {
1136- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1138+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11371139 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11381140 }
11391141 if ( typeof callback !== 'function' ) {
@@ -1155,15 +1157,15 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
11551157
11561158 // https://heycam.github.io/webidl/#es-iterable
11571159 keys ( ) {
1158- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1160+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11591161 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11601162 }
11611163
11621164 return createSearchParamsIterator ( this , 'key' ) ;
11631165 } ,
11641166
11651167 values ( ) {
1166- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1168+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11671169 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11681170 }
11691171
@@ -1173,7 +1175,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
11731175 // https://heycam.github.io/webidl/#es-stringifier
11741176 // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
11751177 toString ( ) {
1176- if ( ! this || ! ( this instanceof URLSearchParams ) ) {
1178+ if ( ! this || ! this [ searchParams ] || this [ searchParams ] [ searchParams ] ) {
11771179 throw new TypeError ( 'Value of `this` is not a URLSearchParams' ) ;
11781180 }
11791181
@@ -1275,8 +1277,10 @@ defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParamsIterator', {
12751277} ) ;
12761278
12771279function originFor ( url , base ) {
1278- if ( ! ( url instanceof URL ) )
1280+ if ( url != undefined &&
1281+ ( ! url [ searchParams ] || ! url [ searchParams ] [ searchParams ] ) ) {
12791282 url = new URL ( url , base ) ;
1283+ }
12801284 var origin ;
12811285 const protocol = url . protocol ;
12821286 switch ( protocol ) {
@@ -1399,8 +1403,10 @@ function getPathFromURLPosix(url) {
13991403}
14001404
14011405function getPathFromURL ( path ) {
1402- if ( ! ( path instanceof URL ) )
1406+ if ( path == undefined || ! path [ searchParams ] ||
1407+ ! path [ searchParams ] [ searchParams ] ) {
14031408 return path ;
1409+ }
14041410 if ( path . protocol !== 'file:' )
14051411 return new TypeError ( 'Only `file:` URLs are supported' ) ;
14061412 return isWindows ? getPathFromURLWin32 ( path ) : getPathFromURLPosix ( path ) ;
0 commit comments