File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,7 @@ fn infer_name_from_ctx(path: &AstNodePath) -> ScopeName {
213213 // An object literal member:
214214 // `{ $name() ... }`
215215 Parent :: MethodProp ( method, _) => {
216+ push_sep ( & mut scope_name) ;
216217 scope_name
217218 . components
218219 . push_front ( prop_name_to_component ( & method. key ) ) ;
@@ -222,6 +223,7 @@ fn infer_name_from_ctx(path: &AstNodePath) -> ScopeName {
222223 // `{ $name: ... }`
223224 Parent :: KeyValueProp ( kv, _) => {
224225 if let Some ( ident) = kv. key . as_ident ( ) {
226+ push_sep ( & mut scope_name) ;
225227 scope_name
226228 . components
227229 . push_front ( NameComponent :: ident ( ident. clone ( ) ) ) ;
Original file line number Diff line number Diff line change @@ -228,3 +228,29 @@ fn extract_empty_function() {
228228 let expected = [ None , None ] ;
229229 assert_eq ! ( scopes, expected) ;
230230}
231+
232+ #[ test]
233+ fn extract_nested_iife_objects ( ) {
234+ // NOTE: This mimicks what react-dom does to transpile JSX children into render tree.
235+ let src = r#"
236+ (function () {})({
237+ children: (function () {})({
238+ children: (function () {})({
239+ onSubmitError () {
240+ throw new Error('wat')
241+ }
242+ })
243+ })
244+ })
245+ "# ;
246+ let scopes = extract_scope_names ( src) . unwrap ( ) ;
247+ let scopes = scope_strs ( scopes) ;
248+
249+ let expected = [
250+ None ,
251+ Some ( "<object>.children" . into ( ) ) ,
252+ Some ( "<object>.children.children" . into ( ) ) ,
253+ Some ( "<object>.children.children.onSubmitError" . into ( ) ) ,
254+ ] ;
255+ assert_eq ! ( scopes, expected) ;
256+ }
You can’t perform that action at this time.
0 commit comments