Skip to content

fix(react-utilities): handle special native prop names - #36806

Open
Paolo Aliprandi (paolo-aliprandi) wants to merge 3 commits into
microsoft:masterfrom
paolo-aliprandi:paliprandi-microsoft-fix-native-prop-filtering
Open

Paolo Aliprandi (paolo-aliprandi) wants to merge 3 commits into
microsoft:masterfrom
paolo-aliprandi:paliprandi-microsoft-fix-native-prop-filtering

Conversation

@paolo-aliprandi

Copy link
Copy Markdown
Contributor

Summary

  • require own-property matches when selecting native element and prop allow-lists
  • preserve the filtered result object's prototype when copying special property names
  • add focused regression coverage and a patch change file

Validation

  • yarn nx run react-utilities:test --runTestsByPath src/utils/getNativeElementProps.test.ts src/utils/properties.test.ts --runInBand
  • yarn nx run react-utilities:lint
  • yarn nx run react-utilities:build
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-accordion
Accordion (including children components)
91.918 kB
29.05 kB
92.893 kB
29.415 kB
975 B
365 B
react-avatar
Avatar
48.392 kB
15.303 kB
49.164 kB
15.65 kB
772 B
347 B
react-avatar
AvatarGroup
17.269 kB
6.89 kB
17.627 kB
7.03 kB
358 B
140 B
react-avatar
AvatarGroupItem
61.376 kB
19.161 kB
62.148 kB
19.511 kB
772 B
350 B
react-badge
Badge
24.126 kB
7.784 kB
24.49 kB
7.923 kB
364 B
139 B
react-badge
CounterBadge
24.848 kB
8.044 kB
25.212 kB
8.182 kB
364 B
138 B
react-badge
PresenceBadge
24.094 kB
8.717 kB
25.018 kB
9.094 kB
924 B
377 B
react-breadcrumb
@fluentui/react-breadcrumb - package
103.667 kB
29.079 kB
104.766 kB
29.505 kB
1.099 kB
426 B
react-button
Button
33.813 kB
8.929 kB
34.065 kB
9.044 kB
252 B
115 B
react-button
CompoundButton
40.693 kB
10.24 kB
40.945 kB
10.362 kB
252 B
122 B
react-button
MenuButton
38.759 kB
10.311 kB
39.729 kB
10.706 kB
970 B
395 B
react-button
SplitButton
48.177 kB
12.046 kB
49.148 kB
12.477 kB
971 B
431 B
react-button
ToggleButton
53.469 kB
11.065 kB
53.722 kB
11.179 kB
253 B
114 B
react-calendar-compat
Calendar Compat
143.32 kB
40.566 kB
144.276 kB
40.982 kB
956 B
416 B
react-card
Card - All
94.104 kB
27.352 kB
94.463 kB
27.485 kB
359 B
133 B
react-card
Card
86.7 kB
25.469 kB
87.059 kB
25.592 kB
359 B
123 B
react-card
CardFooter
12.663 kB
5.028 kB
13.021 kB
5.168 kB
358 B
140 B
react-card
CardHeader
15.21 kB
5.877 kB
15.568 kB
6.015 kB
358 B
138 B
react-card
CardPreview
12.74 kB
5.142 kB
13.099 kB
5.28 kB
359 B
138 B
react-charts
AreaChart
406.902 kB
127.183 kB
408.522 kB
127.732 kB
1.62 kB
549 B
react-charts
DeclarativeChart
758.446 kB
222.689 kB
761.462 kB
223.49 kB
3.016 kB
801 B
react-charts
DonutChart
317.733 kB
97.977 kB
318.853 kB
98.432 kB
1.12 kB
455 B
react-charts
FunnelChart
309.133 kB
94.775 kB
310.268 kB
95.224 kB
1.135 kB
449 B
react-charts
GanttChart
390.032 kB
121.663 kB
391.436 kB
122.159 kB
1.404 kB
496 B
react-charts
GaugeChart
317.083 kB
97.402 kB
318.82 kB
98.004 kB
1.737 kB
602 B
react-charts
GroupedVerticalBarChart
398.115 kB
124.454 kB
399.54 kB
124.94 kB
1.425 kB
486 B
react-charts
HeatMapChart
392.172 kB
122.702 kB
393.63 kB
123.212 kB
1.458 kB
510 B
react-charts
HorizontalBarChart
297.409 kB
90.473 kB
298.531 kB
90.893 kB
1.122 kB
420 B
react-charts
Legends
236.596 kB
71.053 kB
237.644 kB
71.449 kB
1.048 kB
396 B
react-charts
LineChart
418.251 kB
130.314 kB
419.81 kB
130.828 kB
1.559 kB
514 B
react-charts
PolarChart
345.588 kB
108.005 kB
346.705 kB
108.413 kB
1.117 kB
408 B
react-charts
SankeyChart
213.797 kB
68.722 kB
214.531 kB
69.006 kB
734 B
284 B
react-charts
ScatterChart
397.575 kB
124.369 kB
398.987 kB
124.835 kB
1.412 kB
466 B
react-charts
Sparkline
80.888 kB
26.864 kB
81.156 kB
26.99 kB
268 B
126 B
react-charts
VerticalBarChart
434.566 kB
129.339 kB
435.941 kB
129.807 kB
1.375 kB
468 B
react-charts
VerticalStackedBarChart
404.13 kB
125.845 kB
405.539 kB
126.317 kB
1.409 kB
472 B
react-checkbox
Checkbox
30.781 kB
10.914 kB
31.853 kB
11.342 kB
1.072 kB
428 B
react-color-picker
ColorArea
31.032 kB
11.706 kB
31.391 kB
11.836 kB
359 B
130 B
react-color-picker
ColorPicker
16.049 kB
6.438 kB
16.408 kB
6.576 kB
359 B
138 B
react-color-picker
ColorSlider
26.093 kB
10.232 kB
26.452 kB
10.369 kB
359 B
137 B
react-combobox
Combobox (including child components)
139.318 kB
45.067 kB
140.566 kB
45.546 kB
1.248 kB
479 B
react-combobox
Dropdown (including child components)
139.083 kB
44.818 kB
140.365 kB
45.323 kB
1.282 kB
505 B
react-components
react-components: all base hooks
217.423 kB
68.185 kB
218.276 kB
68.431 kB
853 B
246 B
react-components
react-components: Button, FluentProvider & webLightTheme
67.471 kB
19.465 kB
67.836 kB
19.629 kB
365 B
164 B
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
227.136 kB
68.41 kB
228.192 kB
68.813 kB
1.056 kB
403 B
react-components
react-components: FluentProvider & webLightTheme
40.694 kB
13.549 kB
41.066 kB
13.698 kB
372 B
149 B
react-components
react-components: entire library
1.283 MB
322.112 kB
1.285 MB
323.169 kB
2.478 kB
1.057 kB
react-datepicker-compat
DatePicker Compat
217.447 kB
64.407 kB
218.673 kB
64.935 kB
1.226 kB
528 B
react-dialog
Dialog (including children components)
90.984 kB
28.254 kB
92.055 kB
28.666 kB
1.071 kB
412 B
react-divider
Divider
16.233 kB
5.843 kB
16.488 kB
5.963 kB
255 B
120 B
react-field
Field
22.311 kB
8.312 kB
23.331 kB
8.679 kB
1.02 kB
367 B
react-headless-components-preview
react-headless-components-preview: entire library
240.515 kB
67.828 kB
242.254 kB
68.274 kB
1.739 kB
446 B
react-headless-components-preview
@fluentui/react-headless-components-preview/tag-picker
54.012 kB
17.756 kB
54.117 kB
17.778 kB
105 B
22 B
react-headless-components-preview
@fluentui/react-headless-components-preview/teaching-popover
36.073 kB
12.006 kB
36.155 kB
12.018 kB
82 B
12 B
react-image
Image
13.497 kB
5.448 kB
13.855 kB
5.584 kB
358 B
136 B
react-input
Input
26.24 kB
8.643 kB
26.599 kB
8.778 kB
359 B
135 B
react-label
Label
12.843 kB
5.17 kB
13.201 kB
5.309 kB
358 B
139 B
react-link
Link
16.407 kB
6.465 kB
16.77 kB
6.605 kB
363 B
140 B
react-list
List
75.545 kB
23.408 kB
75.906 kB
23.545 kB
361 B
137 B
react-list
ListItem
99.06 kB
30.273 kB
100.134 kB
30.719 kB
1.074 kB
446 B
react-menu
Menu (including children components)
160.788 kB
51.11 kB
161.84 kB
51.505 kB
1.052 kB
395 B
react-menu
Menu (including selectable components)
163.954 kB
51.739 kB
165.005 kB
52.114 kB
1.051 kB
375 B
react-message-bar
MessageBar (all components)
25.293 kB
8.946 kB
26.363 kB
9.349 kB
1.07 kB
403 B
react-persona
Persona
55.345 kB
17.24 kB
56.117 kB
17.596 kB
772 B
356 B
react-popover
Popover
126.6 kB
40.873 kB
127.15 kB
41.085 kB
550 B
212 B
react-portal
Portal
13.844 kB
5.392 kB
14.11 kB
5.518 kB
266 B
126 B
react-positioning
usePositioning
28.985 kB
10.198 kB
29.164 kB
10.252 kB
179 B
54 B
react-positioning
useSafeZoneArea
13.398 kB
5.365 kB
13.461 kB
5.425 kB
63 B
60 B
react-progress
ProgressBar
20.217 kB
7.836 kB
20.578 kB
7.974 kB
361 B
138 B
react-provider
FluentProvider
20.086 kB
7.701 kB
20.458 kB
7.854 kB
372 B
153 B
react-radio
Radio
28.166 kB
9.157 kB
28.523 kB
9.293 kB
357 B
136 B
react-radio
RadioGroup
13.931 kB
5.613 kB
14.29 kB
5.754 kB
359 B
141 B
react-select
Select
26.109 kB
9.403 kB
27.189 kB
9.833 kB
1.08 kB
430 B
react-slider
Slider
33.405 kB
11.51 kB
33.766 kB
11.647 kB
361 B
137 B
react-spinbutton
SpinButton
33.661 kB
11.013 kB
34.739 kB
11.443 kB
1.078 kB
430 B
react-spinner
Spinner
23.603 kB
7.786 kB
23.962 kB
7.928 kB
359 B
142 B
react-swatch-picker
@fluentui/react-swatch-picker - package
93.186 kB
27.608 kB
94.261 kB
28.032 kB
1.075 kB
424 B
react-switch
Switch
33.402 kB
10.566 kB
34.523 kB
10.991 kB
1.121 kB
425 B
react-table
DataGrid
147.809 kB
43.977 kB
148.858 kB
44.4 kB
1.049 kB
423 B
react-table
Table (Primitives only)
38.042 kB
12.69 kB
39.098 kB
13.111 kB
1.056 kB
421 B
react-table
Table as DataGrid
119.68 kB
33.755 kB
120.733 kB
34.194 kB
1.053 kB
439 B
react-table
Table (Selection only)
66.557 kB
18.957 kB
67.604 kB
19.364 kB
1.047 kB
407 B
react-table
Table (Sort only)
65.22 kB
18.58 kB
66.267 kB
18.99 kB
1.047 kB
410 B
react-tag-picker
@fluentui/react-tag-picker - package
174.763 kB
54.56 kB
176.027 kB
55.055 kB
1.264 kB
495 B
react-tags
InteractionTag
13.629 kB
5.386 kB
13.986 kB
5.529 kB
357 B
143 B
react-tags
Tag
29.542 kB
9.338 kB
30.614 kB
9.763 kB
1.072 kB
425 B
react-tags
TagGroup
70.806 kB
21.811 kB
71.167 kB
21.946 kB
361 B
135 B
react-teaching-popover
TeachingPopover
101.77 kB
32.204 kB
101.949 kB
32.262 kB
179 B
58 B
react-text
Text - Default
15.184 kB
5.881 kB
15.542 kB
6.02 kB
358 B
139 B
react-text
Text - Wrappers
18.343 kB
6.196 kB
18.706 kB
6.343 kB
363 B
147 B
react-textarea
Textarea
24.606 kB
8.912 kB
24.964 kB
9.05 kB
358 B
138 B
react-timepicker-compat
TimePicker
142.037 kB
46.44 kB
143.285 kB
46.94 kB
1.248 kB
500 B
react-toast
Toast (including Toaster)
91.488 kB
28.541 kB
91.845 kB
28.678 kB
357 B
137 B
react-tooltip
Tooltip
54.69 kB
19.443 kB
55.146 kB
19.628 kB
456 B
185 B
react-tree
FlatTree
136.693 kB
40.821 kB
137.765 kB
41.232 kB
1.072 kB
411 B
react-tree
PersonaFlatTree
138.556 kB
41.361 kB
139.628 kB
41.755 kB
1.072 kB
394 B
react-tree
PersonaTree
134.637 kB
40.143 kB
135.709 kB
40.531 kB
1.072 kB
388 B
react-tree
Tree
132.78 kB
39.638 kB
133.852 kB
40.028 kB
1.072 kB
390 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
global-context
createContext
510 B
326 B
global-context
createContextSelector
531 B
334 B
react-aria
ARIA - useARIAButtonProps
1.35 kB
631 B
react-aria
ARIA - AriaLiveAnnouncer
3.265 kB
1.499 kB
react-charts
HorizontalBarChartWithAxis
63 B
83 B
react-jsx-runtime
Classic Pragma
1.282 kB
613 B
react-jsx-runtime
JSX Dev Runtime
2.137 kB
988 B
react-jsx-runtime
JSX Runtime
2.134 kB
948 B
react-motion
@fluentui/react-motion - createMotionComponent()
4.275 kB
1.864 kB
react-motion
@fluentui/react-motion - createPresenceComponent()
6.007 kB
2.484 kB
react-motion
@fluentui/react-motion - PresenceGroup
1.715 kB
816 B
react-overflow
hooks only
10.203 kB
3.694 kB
react-portal-compat
PortalCompatProvider
5.341 kB
2.146 kB
react-utilities
SSRProvider
182 B
160 B
🤖 This report was generated against 775d999919dff6e02287ce6a1c07e233af2bf777
@github-actions

Copy link
Copy Markdown

Pull request demo site: URL

): TAttributes {
const allowedPropNames = (tagName && nativeElementMap[tagName]) || htmlElementProperties;
const allowedPropNames =
tagName && Object.prototype.hasOwnProperty.call(nativeElementMap, tagName)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use the https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn

Suggested change
tagName && Object.prototype.hasOwnProperty.call(nativeElementMap, tagName)
tagName && Object.hasOwn(nativeElementMap, tagName)

@paolo-aliprandi Paolo Aliprandi (paolo-aliprandi) Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this suggestion, but react-utilities:build fails with error TS2550 because this package’s configured TypeScript lib does not include Object.hasOwn. I kept Object.prototype.hasOwnProperty.call, which provides the same own-property check and preserves the current build target. Do you think it's ok to proceed in this way?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Martin Hochel (@Hotell) do you think we can tweak ts config to allow using Object.hasOwn?

for (const key of keys) {
const isNativeProp =
(!isArray && (allowedPropNames as Record<string, number>)[key]) ||
(!isArray && Object.prototype.hasOwnProperty.call(allowedPropNames, key)) ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Comment thread packages/react-components/react-utilities/src/utils/properties.test.ts Outdated
Comment thread packages/react-components/react-utilities/src/utils/properties.test.ts Outdated
Comment thread packages/react-components/react-utilities/src/utils/properties.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused fixes have regression coverage, and no unresolved issues were identified.

Review effort: Balanced
Findings: None

What changed in this PR

This PR fixes how react-utilities filters native props with special property names, preventing prototype-chain matches and preserving the filtered result’s prototype.

Changes:

  • Require own-property matches for native element and prop allow-lists.
  • Safely copy an explicitly allowed __proto__ property.
  • Add regression tests and a patch change file.
File Description
packages/​react-components/​react-utilities/​src/​utils/​properties.ts Tightens allow-list matching and safely copies __proto__.
packages/​react-components/​react-utilities/​src/​utils/​properties.test.ts Tests inherited names and result-prototype behavior.
packages/​react-components/​react-utilities/​src/​utils/​getNativeElementProps.ts Avoids inherited tag-name matches.
packages/​react-components/​react-utilities/​src/​utils/​getNativeElementProps.test.ts Tests a prototype-chain tag name.
change/​@fluentui-react-utilities-98768ced-77df-4ff0-942d-db5a851f8745.json Records the patch release.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused implementation and regression tests correctly address the identified prototype-chain edge cases.

Review effort: Balanced
Findings: None

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants