Skip to content

Commit 374deb6

Browse files
committed
Don't try to intercept links inside contenteditable
1 parent ee0ba49 commit 374deb6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function delegateLinkHandler(e) {
117117

118118
let t = e.target;
119119
do {
120-
if (t.localName === 'a' && t.getAttribute('href')) {
120+
if (t.localName === 'a' && t.getAttribute('href') && !t.isContentEditable) {
121121
if (t.hasAttribute('data-native') || t.hasAttribute('native')) return;
122122
// if link is handled by the router, prevent browser defaults
123123
if (routeFromLink(t)) {

test/dom.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,25 @@ describe('dom', () => {
118118
expect(onChange).not.toHaveBeenCalled();
119119
expect(location.href).toContain('#foo');
120120
});
121+
122+
it('should not intercept links inside contenteditable', () => {
123+
let onChange = jasmine.createSpy();
124+
mount(
125+
<div>
126+
<div contenteditable>
127+
<a href="#foo">foo</a>
128+
</div>
129+
<Router onChange={onChange}>
130+
<div default />
131+
</Router>
132+
</div>
133+
);
134+
onChange.calls.reset();
135+
act(() => {
136+
$('a').click();
137+
});
138+
expect(onChange).not.toHaveBeenCalled();
139+
});
121140
});
122141

123142
describe('Router', () => {

0 commit comments

Comments
 (0)