This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix:
BalloonPanelView
should not be focusable. Closes #206.
T/206a: BalloonPanelView should not be focusable
- Loading branch information
Showing
8 changed files
with
134 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/** | ||
* @module ui/bindings/preventdefault | ||
*/ | ||
|
||
/** | ||
* Returns a {module:ui/template~TemplateToBinding} resulting in a native `event#preventDefault` | ||
* for the DOM event if `event#target` equals {@link module:ui/view~View#element}. | ||
* | ||
* @param {module:ui/view~View} view View instance that uses the template. | ||
* @returns {module:ui/template~TemplateToBinding} | ||
*/ | ||
export default function preventDefault( view ) { | ||
return view.bindTemplate.to( evt => { | ||
if ( evt.target === view.element ) { | ||
evt.preventDefault(); | ||
} | ||
} ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/* global Event */ | ||
|
||
import preventDefault from '../../src/bindings/preventdefault'; | ||
import View from '../../src/view'; | ||
import Template from '../../src/template'; | ||
|
||
describe( 'preventDefault', () => { | ||
it( 'prevents default of a native DOM event', () => { | ||
const view = new View(); | ||
|
||
view.template = new Template( { | ||
tag: 'div', | ||
|
||
on: { | ||
foo: preventDefault( view ) | ||
} | ||
} ); | ||
|
||
const evt = new Event( 'foo', { bubbles: true } ); | ||
const spy = sinon.spy( evt, 'preventDefault' ); | ||
|
||
// Render to enable bubbling. | ||
view.element; | ||
|
||
view.element.dispatchEvent( evt ); | ||
sinon.assert.calledOnce( spy ); | ||
} ); | ||
|
||
it( 'prevents only when target is view#element', () => { | ||
const view = new View(); | ||
const child = new View(); | ||
|
||
child.template = new Template( { | ||
tag: 'a' | ||
} ); | ||
|
||
view.template = new Template( { | ||
tag: 'div', | ||
|
||
on: { | ||
foo: preventDefault( view ) | ||
}, | ||
|
||
children: [ | ||
child | ||
] | ||
} ); | ||
|
||
const evt = new Event( 'foo', { bubbles: true } ); | ||
const spy = sinon.spy( evt, 'preventDefault' ); | ||
|
||
// Render to enable bubbling. | ||
view.element; | ||
|
||
child.element.dispatchEvent( evt ); | ||
sinon.assert.notCalled( spy ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters