File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { createContext } from "react" ;
2
2
import ReactLocalization from "./localization" ;
3
3
4
- export default createContext ( new ReactLocalization ( [ ] ) ) ;
4
+ export default createContext ( new ReactLocalization ( [ ] , null ) ) ;
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ function Localized(props) {
135
135
136
136
// If the message value doesn't contain any markup nor any HTML entities,
137
137
// insert it as the only child of the wrapped component.
138
- if ( ! reMarkup . test ( messageValue ) ) {
138
+ if ( ! reMarkup . test ( messageValue ) || l10n . parseMarkup === null ) {
139
139
return cloneElement ( child , localizedProps , messageValue ) ;
140
140
}
141
141
Original file line number Diff line number Diff line change @@ -799,6 +799,27 @@ foo = BEFORE <text-elem>Foo</text-elem> AFTER
799
799
} ) ;
800
800
801
801
describe ( "Localized - custom parseMarkup" , ( ) => {
802
+ test ( "disables the overlay logic if null" , ( ) => {
803
+ const bundle = new FluentBundle ( ) ;
804
+ bundle . addResource ( new FluentResource ( `
805
+ foo = test <em>null markup parser</em>
806
+ ` ) ) ;
807
+
808
+ const renderer = TestRenderer . create (
809
+ < LocalizationProvider bundles = { [ bundle ] } parseMarkup = { null } >
810
+ < Localized id = "foo" >
811
+ < div />
812
+ </ Localized >
813
+ </ LocalizationProvider >
814
+ ) ;
815
+
816
+ expect ( renderer . toJSON ( ) ) . toMatchInlineSnapshot ( `
817
+ <div>
818
+ test <em>null markup parser</em>
819
+ </div>
820
+ ` ) ;
821
+ } ) ;
822
+
802
823
test ( "is called if defined in the context" , ( ) => {
803
824
let parseMarkupCalls = [ ] ;
804
825
You can’t perform that action at this time.
0 commit comments