Revert D119305530: Clone ObjectMethod before toExpression in preset

Differential Revision:
D119305530

Original commit changeset: dd30a94e91ed

Original Phabricator Diff: D119305530

fbshipit-source-id: a38c93b5f7949126f0a33f801f77b01c574e13a3
This commit is contained in:
generatedunixname89002005232357 authored and meta-codesync[bot] committed 2026-09-09 10:22:39 -07:00
1 parent 9b8715910d
commit c1ad8ae2ee
2 files changed
+1 -12

No files matched your search

@@ -493,15 +493,6 @@ describe('Platform.select', () => {
`);
});
test('does not mutate object methods when bailing out on impure initializers', () => {
expectUnchanged(`
const value = require('react-native').Platform.select({
ios() { return 1; },
android: sideEffect(),
});
`);
});
test('does not inline computed keys', () => {
expect(select('{[key]: 1, default: 2}')).toContain('Platform.select');
});
@@ -443,9 +443,7 @@ module.exports = function inlinePlatformPlugin(
if (t.isObjectProperty(property)) {
return property.value;
}
// Clone: toExpression mutates in place, e.g. `ios() {}` would be
// left mutated if the purity check below bails out.
return t.toExpression(t.cloneNode(property));
return t.toExpression(property);
}
}
return fallback();