Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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,23 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import RenderHTML from '../RenderHTML';

/**
* https://github.com/native-html/render/pull/32
*/
describe('RenderHTML component', () => {
describe('should pass regression #32 regarding anchor without href when baseUrl is provided', () => {
it('should mount without throwing', () => {
const { getByText } = render(
<RenderHTML
debug={false}
source={{
html: '<a>link label</a>',
baseUrl: 'https://example.com/'
}}
/>
);
expect(getByText('link label')).toBeTruthy();
});
});
});
3 changes: 2 additions & 1 deletion packages/render/src/renderers/ARenderer.tsx
Comment thread
jsamr marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ function useAnchorOnLinkPress(
const { baseTarget } = useDocumentMetadata();
const shouldHandleLinkPress =
tnode.tagName === 'a' &&
typeof normalizedHref === 'string' &&
typeof href === 'string' &&
href.length > 0 &&
typeof normalizedHref === 'string' &&
typeof onPress === 'function';
return shouldHandleLinkPress
? (e: GestureResponderEvent) =>
Expand Down
Loading