Merge pull request #432 from Mange/follow-details-summary

Allow following <summary> elements
jh-changes
Shin'ya Ueoka 6 years ago committed by GitHub
commit 85e9b9da37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/content/components/common/follow.js
  2. 5
      test/content/components/common/follow.html
  3. 9
      test/content/components/common/follow.test.js

@ -5,7 +5,7 @@ import * as dom from 'shared/utils/dom';
const TARGET_SELECTOR = [ const TARGET_SELECTOR = [
'a', 'button', 'input', 'textarea', 'area', 'a', 'button', 'input', 'textarea', 'area',
'[contenteditable=true]', '[contenteditable=""]', '[tabindex]', '[contenteditable=true]', '[contenteditable=""]', '[tabindex]',
'[role="button"]' '[role="button"]', 'summary'
].join(','); ].join(',');
@ -155,6 +155,7 @@ export default class Follow {
case 'textarea': case 'textarea':
return element.focus(); return element.focus();
case 'button': case 'button':
case 'summary':
return element.click(); return element.click();
default: default:
if (dom.isContentEditable(element)) { if (dom.isContentEditable(element)) {

@ -8,5 +8,10 @@
<div id='editable_div_1' contenteditable>link</div> <div id='editable_div_1' contenteditable>link</div>
<div id='editable_div_2' contenteditable='true'>link</div> <div id='editable_div_2' contenteditable='true'>link</div>
<div id='x' contenteditable='false'>link</div> <div id='x' contenteditable='false'>link</div>
<details>
<summary id='summary_1'>summary link</summary>
Some details
<a href='#'>not visible</a>
</details>
</body> </body>
</html> </html>

@ -11,10 +11,15 @@ describe('FollowComponent', () => {
window, window,
{ width: window.innerWidth, height: window.innerHeight }, { width: window.innerWidth, height: window.innerHeight },
{ x: 0, y: 0 }); { x: 0, y: 0 });
expect(targets).to.have.lengthOf(3); expect(targets).to.have.lengthOf(4);
let ids = Array.prototype.map.call(targets, (e) => e.id); let ids = Array.prototype.map.call(targets, (e) => e.id);
expect(ids).to.include.members(['visible_a', 'editable_div_1', 'editable_div_2']); expect(ids).to.include.members([
'visible_a',
'editable_div_1',
'editable_div_2',
'summary_1',
]);
}); });
}); });
}); });