44import { walk } from 'zimmerframe' ;
55import { object } from '../../../../../utils/ast.js' ;
66import * as b from '#compiler/builders' ;
7+ import * as w from '../../../../../warnings.js' ;
78import { sanitize_template_string } from '../../../../../utils/sanitize_template_string.js' ;
8- import { regex_is_valid_identifier } from '../../../../patterns.js' ;
9+ import {
10+ regex_is_valid_identifier ,
11+ regex_bidirectional_control_characters
12+ } from '../../../../patterns.js' ;
913import is_reference from 'is-reference' ;
1014import { dev , is_ignored , locator } from '../../../../../state.js' ;
1115import { create_derived } from '../../utils.js' ;
@@ -77,7 +81,10 @@ export function build_template_chunk(
7781 // If we have a single expression, then pass that in directly to possibly avoid doing
7882 // extra work in the template_effect (instead we do the work in set_text).
7983 if ( evaluated . is_known ) {
80- value = b . literal ( evaluated . value ) ;
84+ if ( regex_bidirectional_control_characters . test ( ( evaluated . value ?? '' ) + '' ) ) {
85+ w . bidirectional_control_characters_detected ( node ) ;
86+ }
87+ value = b . literal ( ( evaluated . value ?? '' ) + '' ) ;
8188 }
8289
8390 return { value, has_state } ;
@@ -96,7 +103,10 @@ export function build_template_chunk(
96103 }
97104
98105 if ( evaluated . is_known ) {
99- quasi . value . cooked += evaluated . value + '' ;
106+ if ( regex_bidirectional_control_characters . test ( ( evaluated . value ?? '' ) + '' ) ) {
107+ w . bidirectional_control_characters_detected ( node ) ;
108+ }
109+ quasi . value . cooked += ( evaluated . value ?? '' ) + '' ;
100110 } else {
101111 if ( ! evaluated . is_defined ) {
102112 // add `?? ''` where necessary
0 commit comments