Skip to content

[reaxct-dom] Support maskType SVG prop#628

Closed
everettbu wants to merge 1 commit into
mainfrom
fix/svgattr-mask-type-2
Closed

[reaxct-dom] Support maskType SVG prop#628
everettbu wants to merge 1 commit into
mainfrom
fix/svgattr-mask-type-2

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35921
Original author: sleitor


Summary

React currently does not recognize the maskType prop on SVG elements, causing:

  1. The attribute to be rendered as-is (maskType="luminance") rather than the correct mask-type="luminance"
  2. A React warning: "React does not recognize the maskType prop on a DOM element"

The SVG mask-type attribute is valid per MDN and specifies whether a mask is used as a luminance or alpha mask.

Changes

  • getAttributeAlias.js: Add ['maskType', 'mask-type'] to the SVG attribute alias map (alphabetically between markerStart and overlinePosition)
  • possibleStandardNames.js: Add masktype: 'maskType' entry so the dev-mode warning correctly suggests the camelCase spelling

Test

// Before: renders as <mask maskType="luminance"> + React warning
// After: renders as <mask mask-type="luminance"> correctly
<svg>
  <mask id="m" maskType="luminance">...</mask>
</svg>

Fixes #35920

Add maskType → mask-type to the SVG attribute alias map so React
correctly renders <mask maskType="luminance"> as mask-type="luminance"
on the DOM element instead of the unrecognized camelCase prop.

Also add the masktype → maskType entry in possibleStandardNames so the
development warning points users to the correct camelCase spelling.

Fixes: react/react#35920
MDN reference: https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/mask-type
@greptile-apps

greptile-apps Bot commented Feb 27, 2026

Copy link
Copy Markdown

Greptile Summary

Adds support for the SVG mask-type attribute by mapping the camelCase maskType prop to the hyphenated mask-type DOM attribute. The alias in getAttributeAlias.js is correct, but possibleStandardNames.js is missing the 'mask-type': 'maskType' entry that every other hyphenated SVG attribute includes — this means React won't provide a helpful dev warning when mask-type is used directly as a prop name.

Confidence Score: 3/5

  • Low-risk change but incomplete — missing the hyphenated form entry in possibleStandardNames.js breaks the established pattern.
  • The alias mapping is correct and well-placed, but the omission of the 'mask-type': 'maskType' entry in possibleStandardNames.js is inconsistent with how every other hyphenated SVG attribute is handled. This means the dev-mode warning won't work when developers use mask-type directly.
  • packages/react-dom-bindings/src/shared/possibleStandardNames.js needs the missing 'mask-type': 'maskType' entry added.

Important Files Changed

Filename Overview
packages/react-dom-bindings/src/shared/getAttributeAlias.js Correctly adds maskTypemask-type alias in alphabetical order, consistent with existing patterns.
packages/react-dom-bindings/src/shared/possibleStandardNames.js Adds masktype: 'maskType' but is missing the corresponding 'mask-type': 'maskType' entry that all other hyphenated SVG attributes include.

Last reviewed commit: f54905d

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

markerwidth: 'markerWidth',
mask: 'mask',
maskcontentunits: 'maskContentUnits',
masktype: 'maskType',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing hyphenated 'mask-type' entry

Every other hyphenated SVG attribute in this file includes both the lowercased form and the hyphenated form (e.g., markerstart / 'marker-start', clippath / 'clip-path', etc.). The 'mask-type': 'maskType' entry is missing here.

Without it, if a developer writes mask-type directly as a prop (the actual SVG attribute name), React won't map it to maskType and won't provide a helpful dev-mode warning suggesting the correct camelCase spelling.

Suggested change
masktype: 'maskType',
masktype: 'maskType',
'mask-type': 'maskType',
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-dom-bindings/src/shared/possibleStandardNames.js
Line: 317

Comment:
**Missing hyphenated `'mask-type'` entry**

Every other hyphenated SVG attribute in this file includes both the lowercased form and the hyphenated form (e.g., `markerstart` / `'marker-start'`, `clippath` / `'clip-path'`, etc.). The `'mask-type': 'maskType'` entry is missing here.

Without it, if a developer writes `mask-type` directly as a prop (the actual SVG attribute name), React won't map it to `maskType` and won't provide a helpful dev-mode warning suggesting the correct camelCase spelling.

```suggestion
  masktype: 'maskType',
  'mask-type': 'maskType',
```

How can I resolve this? If you propose a fix, please make it concise.

@everettbu everettbu changed the title fix: support maskType SVG attribute as mask-type [reaxct-dom] Support maskType SVG prop Feb 27, 2026
@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Feb 27, 2026
@everettbu
everettbu deleted the fix/svgattr-mask-type-2 branch February 27, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants