@@ -246,15 +246,15 @@ export class XPath {
246246 // expression in an actual context. These factory functions are used
247247 // in the specification of the grammar rules, below.
248248
249- makeTokenExpr ( m ) {
249+ makeTokenExpr ( m : any ) {
250250 return new TokenExpr ( m ) ;
251251 }
252252
253- passExpr ( e ) {
253+ passExpr ( e : any ) {
254254 return e ;
255255 }
256256
257- makeLocationExpr1 ( slash , rel ) {
257+ makeLocationExpr1 ( slash : any , rel : any ) {
258258 rel . absolute = true ;
259259 return rel ;
260260 }
@@ -285,7 +285,7 @@ export class XPath {
285285 return ret ;
286286 }
287287
288- makeLocationExpr6 ( rel , slash , step ) {
288+ makeLocationExpr6 ( rel : any , slash : any , step : any ) {
289289 rel . appendStep ( step ) ;
290290 return rel ;
291291 }
@@ -316,7 +316,7 @@ export class XPath {
316316 return new StepExpr ( 'child' , nodetest , this ) ;
317317 }
318318
319- makeStepExpr6 ( step , predicate ) {
319+ makeStepExpr6 ( step : any , predicate : any ) {
320320 step . appendPredicate ( predicate ) ;
321321 return step ;
322322 }
@@ -338,11 +338,11 @@ export class XPath {
338338 return new NodeTestElementOrAttribute ( ) ;
339339 }
340340
341- makeNodeTestExpr2 ( ncname ) {
341+ makeNodeTestExpr2 ( ncname : any ) {
342342 return new NodeTestNC ( ncname . value ) ;
343343 }
344344
345- makeNodeTestExpr3 ( qname ) {
345+ makeNodeTestExpr3 ( qname : any ) {
346346 return new NodeTestName ( qname . value ) ;
347347 }
348348
@@ -363,27 +363,27 @@ export class XPath {
363363 }
364364 }
365365
366- makeNodeTestExpr5 ( typeo , target ) {
366+ makeNodeTestExpr5 ( typeo : any , target : any ) {
367367 const type = typeo . replace ( / \s * \( $ / , '' ) ;
368368 if ( type != 'processing-instruction' ) {
369369 throw type ;
370370 }
371371 return new NodeTestPI ( target . value ) ;
372372 }
373373
374- makePredicateExpr ( pareno , expr ) {
374+ makePredicateExpr ( pareno : any , expr : any ) {
375375 return new PredicateExpr ( expr ) ;
376376 }
377377
378- makePrimaryExpr ( pareno , expr ) {
378+ makePrimaryExpr ( pareno : any , expr : any ) {
379379 return expr ;
380380 }
381381
382- makeFunctionCallExpr1 ( name ) {
382+ makeFunctionCallExpr1 ( name : any ) {
383383 return new FunctionCallExpr ( name ) ;
384384 }
385385
386- makeFunctionCallExpr2 ( name , pareno , arg1 , args ) {
386+ makeFunctionCallExpr2 ( name : any , pareno : any , arg1 : any , args : any ) {
387387 const ret = new FunctionCallExpr ( name ) ;
388388 ret . appendArg ( arg1 ) ;
389389 for ( let i = 0 ; i < args . length ; ++ i ) {
@@ -392,15 +392,15 @@ export class XPath {
392392 return ret ;
393393 }
394394
395- makeArgumentExpr ( comma , expr ) {
395+ makeArgumentExpr ( comma : any , expr : any ) {
396396 return expr ;
397397 }
398398
399- makeUnionExpr ( expr1 , pipe , expr2 ) {
399+ makeUnionExpr ( expr1 : any , pipe : any , expr2 : any ) {
400400 return new UnionExpr ( expr1 , expr2 ) ;
401401 }
402402
403- makePathExpr1 ( filter , slash , rel ) {
403+ makePathExpr1 ( filter : any , slash : any , rel : any ) {
404404 return new PathExpr ( filter , rel ) ;
405405 }
406406
@@ -409,33 +409,33 @@ export class XPath {
409409 return new PathExpr ( filter , rel ) ;
410410 }
411411
412- makeFilterExpr ( expr , predicates ) {
412+ makeFilterExpr ( expr : any , predicates : any ) {
413413 if ( predicates . length > 0 ) {
414414 return new FilterExpr ( expr , predicates ) ;
415- } else {
416- return expr ;
417415 }
416+
417+ return expr ;
418418 }
419419
420- makeUnaryMinusExpr ( minus , expr ) {
420+ makeUnaryMinusExpr ( minus : any , expr : any ) {
421421 return new UnaryMinusExpr ( expr ) ;
422422 }
423423
424- makeBinaryExpr ( expr1 , op , expr2 ) {
424+ makeBinaryExpr ( expr1 : any , op : any , expr2 : any ) {
425425 return new BinaryExpr ( expr1 , op , expr2 ) ;
426426 }
427427
428- makeLiteralExpr ( token ) {
428+ makeLiteralExpr ( token : any ) {
429429 // remove quotes from the parsed value:
430430 const value = token . value . substring ( 1 , token . value . length - 1 ) ;
431431 return new LiteralExpr ( value ) ;
432432 }
433433
434- makeNumberExpr ( token ) {
434+ makeNumberExpr ( token : any ) {
435435 return new NumberExpr ( token . value ) ;
436436 }
437437
438- makeVariableReference ( dollar , name ) {
438+ makeVariableReference ( dollar : any , name : any ) {
439439 return new VariableExpr ( name . value ) ;
440440 }
441441
@@ -444,21 +444,25 @@ export class XPath {
444444 makeSimpleExpr ( expr : any ) {
445445 if ( expr . charAt ( 0 ) == '$' ) {
446446 return new VariableExpr ( expr . substr ( 1 ) ) ;
447- } else if ( expr . charAt ( 0 ) == '@' ) {
447+ }
448+
449+ if ( expr . charAt ( 0 ) == '@' ) {
448450 let a = new NodeTestName ( expr . substr ( 1 ) ) ;
449451 let b = new StepExpr ( 'attribute' , a , this ) ;
450452 let c = new LocationExpr ( this ) ;
451453 c . appendStep ( b ) ;
452454 return c ;
453- } else if ( expr . match ( / ^ [ 0 - 9 ] + $ / ) ) {
455+ }
456+
457+ if ( expr . match ( / ^ [ 0 - 9 ] + $ / ) ) {
454458 return new NumberExpr ( expr ) ;
455- } else {
456- let a = new NodeTestName ( expr ) ;
457- let b = new StepExpr ( 'child' , a , this ) ;
458- let c = new LocationExpr ( this ) ;
459- c . appendStep ( b ) ;
460- return c ;
461459 }
460+
461+ let a = new NodeTestName ( expr ) ;
462+ let b = new StepExpr ( 'child' , a , this ) ;
463+ let c = new LocationExpr ( this ) ;
464+ c . appendStep ( b ) ;
465+ return c ;
462466 }
463467
464468 makeSimpleExpr2 ( expr : any ) {
@@ -472,7 +476,7 @@ export class XPath {
472476 return c ;
473477 }
474478
475- stackToString ( stack ) {
479+ stackToString ( stack : any [ ] ) {
476480 let ret = '' ;
477481 for ( let i = 0 ; i < stack . length ; ++ i ) {
478482 if ( ret ) {
@@ -483,7 +487,7 @@ export class XPath {
483487 return ret ;
484488 }
485489
486- xPathCacheLookup ( expr ) {
490+ xPathCacheLookup ( expr : any ) {
487491 return this . xPathParseCache [ expr ] ;
488492 }
489493
@@ -498,7 +502,7 @@ export class XPath {
498502 }
499503 }
500504
501- xPathCollectDescendantsReverse ( nodelist , node ) {
505+ xPathCollectDescendantsReverse ( nodelist : any , node : any ) {
502506 for ( let n = node . lastChild ; n ; n = n . previousSibling ) {
503507 nodelist . push ( n ) ;
504508 this . xPathCollectDescendantsReverse ( nodelist , n ) ;
@@ -522,10 +526,11 @@ export class XPath {
522526 * non-element nodes. This can boost
523527 * performance. This is false by default.
524528 */
525- xPathExtractTagNameFromNodeTest ( nodetest , ignoreNonElementNodesForNTA ) {
529+ xPathExtractTagNameFromNodeTest ( nodetest : any , ignoreNonElementNodesForNTA : any ) {
526530 if ( nodetest instanceof NodeTestName ) {
527531 return nodetest . name ;
528532 }
533+
529534 if (
530535 ( ignoreNonElementNodesForNTA && nodetest instanceof NodeTestAny ) ||
531536 nodetest instanceof NodeTestElementOrAttribute
@@ -534,7 +539,7 @@ export class XPath {
534539 }
535540 }
536541
537- xPathMatchStack ( stack , pattern ) {
542+ xPathMatchStack ( stack : any , pattern : any ) {
538543 // NOTE(mesch): The stack matches for variable cardinality are
539544 // greedy but don't do backtracking. This would be an issue only
540545 // with rules of the form A* A, i.e. with an element with variable
@@ -601,11 +606,13 @@ export class XPath {
601606 }
602607 }
603608
604- // The entry point for the parser.
605- //
606- // @param expr a string that contains an XPath expression.
607- // @return an expression object that can be evaluated with an
608- // expression context.
609+ /**
610+ * The entry point for the parser.
611+ * @param expr a string that contains an XPath expression.
612+ * @param xpathLog TODO
613+ * @returns an expression object that can be evaluated with an
614+ * expression context.
615+ */
609616 xPathParse (
610617 expr ,
611618 xpathLog = ( message : string ) => {
@@ -732,7 +739,7 @@ export class XPath {
732739 return result ;
733740 }
734741
735- xPathParseInit ( xpathLog ) {
742+ xPathParseInit ( xPathLog : Function ) {
736743 if ( this . xPathRules . length ) {
737744 return ;
738745 }
@@ -782,7 +789,7 @@ export class XPath {
782789 xpathTokenRules [ i ] . key = k ++ ;
783790 }
784791
785- xpathLog ( `XPath parse INIT: ${ k } rules` ) ;
792+ xPathLog ( `XPath parse INIT: ${ k } rules` ) ;
786793
787794 // Another slight optimization: sort the rules into bins according
788795 // to the last element (observing quantifiers), so we can restrict
@@ -793,7 +800,7 @@ export class XPath {
793800 // bison, so that we don't have to do any explicit and iterated
794801 // match against the stack.
795802
796- function push_ ( array , position , element ) {
803+ function push_ ( array : any , position : any , element : any ) {
797804 if ( ! array [ position ] ) {
798805 array [ position ] = [ ] ;
799806 }
@@ -818,16 +825,16 @@ export class XPath {
818825 }
819826 }
820827
821- xpathLog ( `XPath parse INIT: ${ this . xPathRules . length } rule bins` ) ;
828+ xPathLog ( `XPath parse INIT: ${ this . xPathRules . length } rule bins` ) ;
822829
823830 let sum = 0 ;
824- mapExec ( this . xPathRules , ( i ) => {
831+ mapExec ( this . xPathRules , ( i : any ) => {
825832 if ( i ) {
826833 sum += i . length ;
827834 }
828835 } ) ;
829836
830- xpathLog ( `XPath parse INIT: ${ sum / this . xPathRules . length } average bin size` ) ;
837+ xPathLog ( `XPath parse INIT: ${ sum / this . xPathRules . length } average bin size` ) ;
831838 }
832839
833840 /*DGF xpathReduce is where the magic happens in this parser.
@@ -919,7 +926,7 @@ export class XPath {
919926
920927 // Utility function to sort a list of nodes. Used by xsltSort() and
921928 // nxslSelect().
922- xPathSort ( input , sort ) {
929+ xPathSort ( input : any , sort : any ) {
923930 if ( sort . length == 0 ) {
924931 return ;
925932 }
@@ -977,7 +984,7 @@ export class XPath {
977984 // NOTE: In browsers which do not follow the spec, this breaks only in
978985 // the case that numbers should be sorted as strings, which is very
979986 // uncommon.
980- xPathSortByKey ( v1 , v2 ) {
987+ xPathSortByKey ( v1 : any , v2 : any ) {
981988 // NOTE: Sort key vectors of different length never occur in
982989 // xsltSort.
983990
@@ -993,7 +1000,7 @@ export class XPath {
9931000 return 0 ;
9941001 }
9951002
996- xPathStep ( nodes : any [ ] , steps : any [ ] , step , input , ctx ) {
1003+ xPathStep ( nodes : any [ ] , steps : any [ ] , step : any , input : any , ctx : any ) {
9971004 const s = steps [ step ] ;
9981005 const ctx2 = ctx . clone ( input ) ;
9991006
@@ -1041,7 +1048,7 @@ export class XPath {
10411048 }
10421049 }
10431050
1044- xPathGrammarPrecedence ( frame ) {
1051+ xPathGrammarPrecedence ( frame : any ) {
10451052 let ret = 0 ;
10461053
10471054 if ( frame . rule ) {
@@ -1068,7 +1075,7 @@ export class XPath {
10681075 return ret ;
10691076 }
10701077
1071- xPathTokenPrecedence ( tag ) {
1078+ xPathTokenPrecedence ( tag : any ) {
10721079 return tag . prec || 2 ;
10731080 }
10741081}
0 commit comments