File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
const utils = require ( '../utils.js' ) ;
4
4
5
- // HTML regex (modified from jQuery)
6
- const rquickExpr = / ^ (?: \s * ( < [ \w \W ] + > ) [ ^ > ] * ) $ / ;
7
5
// Single tag regex (from jQuery)
8
6
const rsingleTag = / ^ < ( [ a - z ] [ ^ / \0 > : \x20 \t \r \n \f ] * ) [ \x20 \t \r \n \f ] * \/ ? > (?: < \/ \1> | ) $ / i;
9
7
const rsingleTagMinimal = / ^ < ( [ a - z ] [ ^ / \0 > : \x20 \t \r \n \f ] * ) > $ / i;
@@ -74,11 +72,10 @@ module.exports = {
74
72
let expectedTag ;
75
73
const arg = node . arguments [ 0 ] ;
76
74
if ( allowSingle ) {
77
- const value = arg && utils . allLiteral ( arg ) && utils . joinLiterals ( arg ) ;
78
- if ( ! ( typeof value === 'string' && value ) || ! rquickExpr . exec ( value ) ) {
79
- // Empty or non-string, or non-HTML
75
+ if ( ! utils . isHtmlString ( arg ) ) {
80
76
return ;
81
77
}
78
+ const value = utils . joinLiterals ( arg ) ;
82
79
let match ;
83
80
if ( ( match = rsingleTag . exec ( value ) ) ) {
84
81
// Single tag
Original file line number Diff line number Diff line change @@ -562,6 +562,14 @@ function joinLiterals( node ) {
562
562
}
563
563
}
564
564
565
+ // HTML regex (modified from jQuery)
566
+ const rquickExpr = / ^ (?: \s * ( < [ \w \W ] + > ) [ ^ > ] * ) $ / ;
567
+
568
+ function isHtmlString ( arg ) {
569
+ const value = arg && allLiteral ( arg ) && joinLiterals ( arg ) ;
570
+ return typeof value === 'string' && value && rquickExpr . exec ( value ) ;
571
+ }
572
+
565
573
module . exports = {
566
574
isjQuery,
567
575
isjQueryConstructor,
@@ -575,5 +583,6 @@ module.exports = {
575
583
jQueryCollectionLink,
576
584
jQueryGlobalLink,
577
585
allLiteral,
578
- joinLiterals
586
+ joinLiterals,
587
+ isHtmlString
579
588
} ;
You can’t perform that action at this time.
0 commit comments