@@ -28,14 +28,15 @@ export default class JavascriptParser extends Parser<ScriptEvents> {
28
28
engine . on ( 'element::script' , this . parseJavascriptTag . bind ( this ) ) ;
29
29
}
30
30
31
- private async emitScript ( code : string , resource : string ) {
31
+ private async emitScript ( code : string , resource : string , element : IAsyncHTMLElement | null ) {
32
32
try {
33
33
await this . engine . emitAsync ( `parse::start::javascript` , { resource } ) ;
34
34
35
35
const ast : AST . Program = espree . parse ( code , defaultParserOptions ) ;
36
36
37
37
await this . engine . emitAsync ( `parse::end::javascript` , {
38
38
ast,
39
+ element,
39
40
resource,
40
41
sourceCode : new SourceCode ( code , ast )
41
42
} ) ;
@@ -48,7 +49,7 @@ export default class JavascriptParser extends Parser<ScriptEvents> {
48
49
const code = fetchEnd . response . body . content ;
49
50
const resource = fetchEnd . resource ;
50
51
51
- await this . emitScript ( code , resource ) ;
52
+ await this . emitScript ( code , resource , null ) ;
52
53
}
53
54
54
55
private hasSrcAttribute ( element : IAsyncHTMLElement ) {
@@ -91,6 +92,6 @@ export default class JavascriptParser extends Parser<ScriptEvents> {
91
92
const code = this . getScriptContent ( await element . outerHTML ( ) ) ;
92
93
const resource : string = 'Internal javascript' ;
93
94
94
- await this . emitScript ( code , resource ) ;
95
+ await this . emitScript ( code , resource , element ) ;
95
96
}
96
97
}
0 commit comments