File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
errors/src/compiler/error-info
template-compiler/src/parser Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 5
5
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
*/
7
7
/**
8
- * Next error code: 1203
8
+ * Next error code: 1204
9
9
*/
10
10
11
11
export * from './compiler' ;
Original file line number Diff line number Diff line change @@ -955,4 +955,12 @@ export const ParserDiagnostics = {
955
955
level : DiagnosticLevel . Error ,
956
956
url : '' ,
957
957
} ,
958
+
959
+ INVALID_LWC_ON_LITERAL_PROP : {
960
+ code : 1203 ,
961
+ message :
962
+ 'Invalid lwc:on usage on element "{0}". The directive binding must be an expression.' ,
963
+ level : DiagnosticLevel . Error ,
964
+ url : '' ,
965
+ } ,
958
966
} ;
Original file line number Diff line number Diff line change @@ -884,6 +884,7 @@ const LWC_DIRECTIVE_PROCESSORS = [
884
884
applyLwcInnerHtmlDirective ,
885
885
applyRefDirective ,
886
886
applyLwcSpreadDirective ,
887
+ applyLwcOnDirective ,
887
888
applyLwcSlotBindDirective ,
888
889
] ;
889
890
@@ -972,6 +973,26 @@ function applyLwcSpreadDirective(
972
973
element . directives . push ( ast . spreadDirective ( lwcSpreadAttr , lwcSpread . location ) ) ;
973
974
}
974
975
976
+ function applyLwcOnDirective (
977
+ ctx : ParserCtx ,
978
+ parsedAttr : ParsedAttribute ,
979
+ element : BaseElement
980
+ ) : void {
981
+ const { name : tag } = element ;
982
+
983
+ const lwcOn = parsedAttr . pick ( ElementDirectiveName . On ) ;
984
+ if ( ! lwcOn ) {
985
+ return ;
986
+ }
987
+
988
+ const { value : lwcOnValue } = lwcOn ;
989
+ if ( ! ast . isExpression ( lwcOnValue ) ) {
990
+ ctx . throwOnNode ( ParserDiagnostics . INVALID_LWC_ON_LITERAL_PROP , element , [ `<${ tag } >` ] ) ;
991
+ }
992
+
993
+ element . directives . push ( ast . OnDirective ( lwcOnValue , lwcOn . location ) ) ;
994
+ }
995
+
975
996
function applyLwcExternalDirective (
976
997
ctx : ParserCtx ,
977
998
parsedAttr : ParsedAttribute ,
You can’t perform that action at this time.
0 commit comments