@@ -10,14 +10,16 @@ const FramePatternMatcher = {};
10
10
* A list of the matched rules is returned.
11
11
*
12
12
*/
13
- FramePatternMatcher . testRules = function ( rules , frame , onmatch ) {
14
- const matched_rules = [ ] ;
15
- for ( let i = 0 ; i < rules . length ; i ++ ) {
16
- const match = ( ! rules [ i ] . pattern || this . patternMatchesFrame ( rules [ i ] . pattern , frame ) ) ;
17
- if ( match ) {
18
- matched_rules . push ( rules [ i ] ) ;
19
- if ( onmatch && typeof onmatch === 'function' ) {
20
- onmatch ( frame , rules [ i ] ) ;
13
+ FramePatternMatcher . testRules = function ( rules , frame , onmatch ) {
14
+ var matched_rules = [ ] ;
15
+ if ( rules && rules . length ) {
16
+ for ( var i = 0 ; i < rules . length ; i ++ ) {
17
+ var match = ( ! rules [ i ] . pattern || FramePatternMatcher . patternMatchesFrame ( rules [ i ] . pattern , frame ) ) ;
18
+ if ( match ) {
19
+ matched_rules . push ( rules [ i ] ) ;
20
+ if ( onmatch && typeof onmatch == "function" ) {
21
+ onmatch ( frame , rules [ i ] ) ;
22
+ }
21
23
}
22
24
}
23
25
}
@@ -64,8 +66,8 @@ FramePattern = function (pattern) {
64
66
}
65
67
} ;
66
68
67
- FramePattern . prototype . setPattern = function ( pattern ) {
68
- this . renderer = ( pattern . renderer ? pattern . renderer : false ) ;
69
+ FramePattern . prototype . setPattern = function ( pattern ) {
70
+ this . scope = ( pattern . scope ? pattern . scope : false ) ;
69
71
this . label = ( pattern . label ? pattern . label : false ) ;
70
72
this . frame_type = ( pattern . frame_type ? pattern . frame_type : false ) ;
71
73
this . subject = ( pattern . subject ? pattern . subject : false ) ;
@@ -83,25 +85,25 @@ FramePattern.prototype.setPattern = function (pattern) {
83
85
this . depth = ( typeof pattern . depth !== 'undefined' ? pattern . depth : false ) ;
84
86
this . index = ( pattern . index ? pattern . index : false ) ;
85
87
this . status = ( pattern . status ? pattern . status : false ) ;
86
- } ;
88
+ }
87
89
88
- FramePattern . prototype . checkFrame = function ( frame ) {
89
- const rtype = this . getRendererType ( frame ) ;
90
- if ( ! rtype ) return false ;
91
- if ( this . renderer && ( this . renderer != rtype ) && ( this . renderer != '*' ) ) return false ;
92
- if ( this . illegalRuleType ( rtype ) ) return false ;
93
- if ( this . frame_type && ! this . checkFrameType ( rtype , frame ) ) return false ;
94
- if ( this . label && ! this . checkLabel ( rtype , frame ) ) return false ;
95
- if ( this . subject && ! this . checkSubject ( rtype , frame ) ) return false ;
96
- if ( this . subjectClass && ! this . checkSubjectClass ( rtype , frame ) ) return false ;
97
- if ( this . property && ! this . checkProperty ( rtype , frame ) ) return false ;
98
- if ( this . depth !== false && ! this . checkDepth ( rtype , frame ) ) return false ;
99
- if ( this . range && ! this . checkRange ( rtype , frame ) ) return false ;
100
- if ( this . value && ! this . checkValue ( rtype , frame ) ) return false ;
101
- if ( this . parent && ! this . checkParent ( rtype , frame ) ) return false ;
102
- if ( this . children && this . children . length && ! this . checkChildren ( rtype , frame ) ) return false ;
103
- if ( this . index && ! this . checkIndex ( rtype , frame ) ) return false ;
104
- if ( this . status && ! this . checkStatus ( rtype , frame ) ) return false ;
90
+ FramePattern . prototype . checkFrame = function ( frame ) {
91
+ var rtype = this . getRendererType ( frame ) ;
92
+ if ( ! rtype ) return false ;
93
+ if ( this . scope && ( this . scope != rtype ) && ( this . scope != "*" ) ) return false ;
94
+ if ( this . illegalRuleType ( rtype ) ) return false ;
95
+ if ( this . frame_type && ! this . checkFrameType ( rtype , frame ) ) return false ;
96
+ if ( this . label && ! this . checkLabel ( rtype , frame ) ) return false ;
97
+ if ( this . subject && ! this . checkSubject ( rtype , frame ) ) return false ;
98
+ if ( this . subjectClass && ! this . checkSubjectClass ( rtype , frame ) ) return false ;
99
+ if ( this . property && ! this . checkProperty ( rtype , frame ) ) return false ;
100
+ if ( this . depth !== false && ! this . checkDepth ( rtype , frame ) ) return false ;
101
+ if ( this . range && ! this . checkRange ( rtype , frame ) ) return false ;
102
+ if ( this . value && ! this . checkValue ( rtype , frame ) ) return false ;
103
+ if ( this . parent && ! this . checkParent ( rtype , frame ) ) return false ;
104
+ if ( this . children && this . children . length && ! this . checkChildren ( rtype , frame ) ) return false ;
105
+ if ( this . index && ! this . checkIndex ( rtype , frame ) ) return false ;
106
+ if ( this . status && ! this . checkStatus ( rtype , frame ) ) return false ;
105
107
return true ;
106
108
} ;
107
109
@@ -299,12 +301,12 @@ function FrameRule() {
299
301
return this ;
300
302
}
301
303
302
- FrameRule . prototype . renderer = function ( ... rend ) {
303
- this . rule . pattern . renderer = rend ;
304
+ FrameRule . prototype . scope = function ( scope ) {
305
+ this . rule . pattern . scope = scope ;
304
306
return this ;
305
307
} ;
306
308
307
- FrameRule . prototype . setRenderer = function ( rend ) {
309
+ FrameRule . prototype . renderer = function ( rend ) {
308
310
this . rule . renderer = rend ;
309
311
return this ;
310
312
} ;
@@ -398,4 +400,4 @@ FrameRule.prototype.status = function (...status) {
398
400
} ;
399
401
400
402
401
- module . exports = { FramePatternMatcher, FrameRule } ;
403
+ module . exports = { FramePatternMatcher, FramePattern , FrameRule } ;
0 commit comments