Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Comment thread
dmytrokirpa marked this conversation as resolved.
"type": "patch",
"comment": "fix: Add loading to img element property whitelist",
"packageName": "@fluentui/react-utilities",
"email": "84954628+lukiod@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as React from 'react';
import { getNativeProps, divProperties, inputProperties, anchorProperties, buttonProperties } from './properties';
import { getNativeProps, divProperties, inputProperties, anchorProperties, buttonProperties, imgProperties } from './properties';

describe('getNativeProps', () => {
it('can pass through data tags', () => {
Expand Down Expand Up @@ -113,6 +113,27 @@ describe('getNativeProps', () => {
expect(result).not.toHaveProperty('foobar');
});

it('can pass through img props including loading', () => {
const result = getNativeProps<React.ImgHTMLAttributes<HTMLImageElement>>(
{
src: 'https://example.com/image.png',
alt: 'An image',
loading: 'lazy',
// Non-img property
foobar: 1,
},
imgProperties,
);

expect(result).toMatchObject({
src: 'https://example.com/image.png',
alt: 'An image',
loading: 'lazy',
});

expect(result).not.toHaveProperty('foobar');
});

describe('popover', () => {
it('allows the popoverTarget attribute on button', () => {
const result = getNativeProps<React.HTMLAttributes<HTMLButtonElement>>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ export const imgProperties = toObjectMap(htmlElementProperties, [
'alt', // area, img, input
'crossOrigin', // img
'height', // canvas, embed, iframe, img, input, object, video
'loading', // img, iframe
'src', // audio, embed, iframe, img, input, script, source, track, video
'srcSet', // img, source
'useMap', // img, object,
Expand Down
Loading