File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -252,18 +252,23 @@ exports.DOMString = (value, options = {}) => {
252252
253253exports . ByteString = ( value , options = { } ) => {
254254 const x = exports . DOMString ( value , options ) ;
255- let c ;
256- for ( let i = 0 ; ( c = x . codePointAt ( i ) ) !== undefined ; ++ i ) {
257- if ( c > 255 ) {
258- throw makeException ( TypeError , "is not a valid ByteString" , options ) ;
259- }
255+
256+ // Unicode regex is identical here but is ~5x slower on 16-bit strings
257+ // eslint-disable-next-line require-unicode-regexp
258+ if ( ! / [ ^ \x00 - \xff ] / . test ( x ) ) {
259+ return x ;
260260 }
261261
262- return x ;
262+ throw makeException ( TypeError , "is not a valid ByteString" , options ) ;
263263} ;
264264
265265exports . USVString = ( value , options = { } ) => {
266266 const S = exports . DOMString ( value , options ) ;
267+
268+ if ( S . toWellFormed ) {
269+ return S . toWellFormed ( ) ;
270+ }
271+
267272 const n = S . length ;
268273 const U = [ ] ;
269274 for ( let i = 0 ; i < n ; ++ i ) {
You can’t perform that action at this time.
0 commit comments