Skip to content

Commit c1ad8ae

Browse files
generatedunixname89002005232357meta-codesync[bot]
authored andcommitted
Revert D119305530: Clone ObjectMethod before toExpression in preset
Differential Revision: D119305530 Original commit changeset: dd30a94e91ed Original Phabricator Diff: D119305530 fbshipit-source-id: a38c93b5f7949126f0a33f801f77b01c574e13a3
1 parent 9b87159 commit c1ad8ae

2 files changed

Lines changed: 1 addition & 12 deletions

File tree

‎packages/react-native-babel-preset/src/__tests__/inline-platform-plugin-test.js‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,6 @@ describe('Platform.select', () => {
493493
`);
494494
});
495495

496-
test('does not mutate object methods when bailing out on impure initializers', () => {
497-
expectUnchanged(`
498-
const value = require('react-native').Platform.select({
499-
ios() { return 1; },
500-
android: sideEffect(),
501-
});
502-
`);
503-
});
504-
505496
test('does not inline computed keys', () => {
506497
expect(select('{[key]: 1, default: 2}')).toContain('Platform.select');
507498
});

‎packages/react-native-babel-preset/src/inline-platform-plugin.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,7 @@ module.exports = function inlinePlatformPlugin(
443443
if (t.isObjectProperty(property)) {
444444
return property.value;
445445
}
446-
// Clone: toExpression mutates in place, e.g. `ios() {}` would be
447-
// left mutated if the purity check below bails out.
448-
return t.toExpression(t.cloneNode(property));
446+
return t.toExpression(property);
449447
}
450448
}
451449
return fallback();

0 commit comments

Comments
 (0)