@@ -2,7 +2,14 @@ import { Events } from './events'
2
2
import { escapeHTML } from '../helpers/sanitize'
3
3
4
4
export class Attributes {
5
- static CUSTOM_ATTRIBUTES = [ ':class' , ':text' , ':value' , ':checked' , ':each' ]
5
+ static CUSTOM_ATTRIBUTES = [
6
+ ':class' ,
7
+ ':text' ,
8
+ ':value' ,
9
+ ':checked' ,
10
+ ':each' ,
11
+ ':parent' ,
12
+ ]
6
13
static FORBIDDEN_ATTRIBUTES = [ ':innerHTML' , ':innerText' ]
7
14
8
15
static isValidAttribute ( attribute , element ) {
@@ -52,7 +59,8 @@ export class Attributes {
52
59
53
60
async evaluateAttribute ( attr ) {
54
61
if ( ! Attributes . isValidAttribute ( attr , this . base . element ) ) return
55
- if ( attr === ':class' ) await this . evaluateClass ( )
62
+ if ( attr === ':parent' ) this . evaluateParent ( )
63
+ else if ( attr === ':class' ) await this . evaluateClass ( )
56
64
else if ( attr === ':text' ) await this . evaluateText ( )
57
65
else if ( [ ':value' , ':checked' ] . includes ( attr ) ) await this . evaluateValue ( )
58
66
else if ( attr === ':each' ) await this . evaluateEach ( )
@@ -63,6 +71,12 @@ export class Attributes {
63
71
}
64
72
}
65
73
74
+ evaluateParent ( ) {
75
+ if ( ! this . base . element . hasAttribute ( ':parent' ) ) return
76
+ if ( this . base . isParent ( ) ) return
77
+ this . base . setAsParent ( )
78
+ }
79
+
66
80
async evaluateClass ( ) {
67
81
const expr = this . base . element . getAttribute ( ':class' )
68
82
if ( ! expr ) return
0 commit comments