mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-24 23:25:40 +00:00
[fix] Allow href 'target' string to start with underscore
Fix #1963 Close #1937
This commit is contained in:
@@ -107,6 +107,15 @@ exports[`components/Text prop "hrefAttrs" requires "href" 1`] = `
|
||||
/>
|
||||
`;
|
||||
|
||||
exports[`components/Text prop "hrefAttrs" target variant is set 1`] = `
|
||||
<a
|
||||
class="css-reset-4rbku5 css-text-901oao"
|
||||
dir="auto"
|
||||
href="https://example.com"
|
||||
target="_blank"
|
||||
/>
|
||||
`;
|
||||
|
||||
exports[`components/Text prop "hrefAttrs" value is set 1`] = `
|
||||
<a
|
||||
class="css-reset-4rbku5 css-text-901oao"
|
||||
|
||||
@@ -83,6 +83,14 @@ describe('components/Text', () => {
|
||||
const hrefAttrs = {
|
||||
download: 'filename.jpg',
|
||||
rel: 'nofollow',
|
||||
target: '_blank'
|
||||
};
|
||||
const { container } = render(<Text href="https://example.com" hrefAttrs={hrefAttrs} />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('target variant is set', () => {
|
||||
const hrefAttrs = {
|
||||
target: 'blank'
|
||||
};
|
||||
const { container } = render(<Text href="https://example.com" hrefAttrs={hrefAttrs} />);
|
||||
|
||||
+2
-2
@@ -131,8 +131,8 @@ const Text = forwardRef<TextProps, *>((props, forwardedRef) => {
|
||||
if (rel != null) {
|
||||
supportedProps.rel = rel;
|
||||
}
|
||||
if (typeof target === 'string' && target.charAt(0) !== '_') {
|
||||
supportedProps.target = '_' + target;
|
||||
if (typeof target === 'string') {
|
||||
supportedProps.target = target.charAt(0) !== '_' ? '_' + target : target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,14 @@ exports[`components/View prop "hrefAttrs" requires "href" 1`] = `
|
||||
/>
|
||||
`;
|
||||
|
||||
exports[`components/View prop "hrefAttrs" target variant is set 1`] = `
|
||||
<a
|
||||
class="css-reset-4rbku5 css-view-1dbjc4n"
|
||||
href="https://example.com"
|
||||
target="_blank"
|
||||
/>
|
||||
`;
|
||||
|
||||
exports[`components/View prop "hrefAttrs" value is set 1`] = `
|
||||
<a
|
||||
class="css-reset-4rbku5 css-view-1dbjc4n"
|
||||
|
||||
@@ -116,6 +116,14 @@ describe('components/View', () => {
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('target variant is set', () => {
|
||||
const hrefAttrs = {
|
||||
target: 'blank'
|
||||
};
|
||||
const { container } = render(<View href="https://example.com" hrefAttrs={hrefAttrs} />);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('null values are excluded', () => {
|
||||
const hrefAttrs = {
|
||||
download: null,
|
||||
|
||||
Reference in New Issue
Block a user