Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 1823196

Browse files
authored
Merge pull request #220 from ckeditor/t/219
Other: Renamed `isDomNode()` to `isNode()`. Closes #219. BREAKING CHANGE: `isDomNode()` was renamed to `isNode()`.
2 parents a9a6bec + d487dd7 commit 1823196

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/dom/emittermixin.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { default as EmitterMixin, _getEmitterListenedTo, _setEmitterId } from '../emittermixin';
1111
import uid from '../uid';
1212
import extend from '../lib/lodash/extend';
13-
import isDomNode from './isdomnode';
13+
import isNode from './isnode';
1414
import isWindow from './iswindow';
1515

1616
/**
@@ -53,7 +53,7 @@ const DomEmitterMixin = extend( {}, EmitterMixin, {
5353
listenTo( emitter, ...rest ) {
5454
// Check if emitter is an instance of DOM Node. If so, replace the argument with
5555
// corresponding ProxyEmitter (or create one if not existing).
56-
if ( isDomNode( emitter ) || isWindow( emitter ) ) {
56+
if ( isNode( emitter ) || isWindow( emitter ) ) {
5757
const proxy = this._getProxyEmitter( emitter ) || new ProxyEmitter( emitter );
5858

5959
proxy.attach( ...rest );
@@ -82,7 +82,7 @@ const DomEmitterMixin = extend( {}, EmitterMixin, {
8282
*/
8383
stopListening( emitter, event, callback ) {
8484
// Check if emitter is an instance of DOM Node. If so, replace the argument with corresponding ProxyEmitter.
85-
if ( isDomNode( emitter ) || isWindow( emitter ) ) {
85+
if ( isNode( emitter ) || isWindow( emitter ) ) {
8686
const proxy = this._getProxyEmitter( emitter );
8787

8888
// Element has no listeners.

src/dom/isdomnode.js renamed to src/dom/isnode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
/**
7-
* @module utils/dom/isdomnode
7+
* @module utils/dom/isnode
88
*/
99

1010
/**
@@ -13,7 +13,7 @@
1313
* @param {*} obj
1414
* @returns {Boolean}
1515
*/
16-
export default function isDomNode( obj ) {
16+
export default function isNode( obj ) {
1717
if ( obj ) {
1818
if ( obj.defaultView ) {
1919
return obj instanceof obj.defaultView.Document;

tests/dom/isdomnode.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55

66
/* global document, window */
77

8-
import isDomNode from '../../src/dom/isdomnode';
8+
import isNode from '../../src/dom/isnode';
99

10-
describe( 'isDomNode()', () => {
10+
describe( 'isNode()', () => {
1111
it( 'detects native DOM nodes', () => {
12-
expect( isDomNode( document ) ).to.be.true;
13-
expect( isDomNode( document.createElement( 'div' ) ) ).to.be.true;
14-
expect( isDomNode( document.createTextNode( 'Foo' ) ) ).to.be.true;
15-
16-
expect( isDomNode( {} ) ).to.be.false;
17-
expect( isDomNode( null ) ).to.be.false;
18-
expect( isDomNode( undefined ) ).to.be.false;
19-
expect( isDomNode( new Date() ) ).to.be.false;
20-
expect( isDomNode( 42 ) ).to.be.false;
21-
expect( isDomNode( window ) ).to.be.false;
12+
expect( isNode( document ) ).to.be.true;
13+
expect( isNode( document.createElement( 'div' ) ) ).to.be.true;
14+
expect( isNode( document.createTextNode( 'Foo' ) ) ).to.be.true;
15+
16+
expect( isNode( {} ) ).to.be.false;
17+
expect( isNode( null ) ).to.be.false;
18+
expect( isNode( undefined ) ).to.be.false;
19+
expect( isNode( new Date() ) ).to.be.false;
20+
expect( isNode( 42 ) ).to.be.false;
21+
expect( isNode( window ) ).to.be.false;
2222
} );
2323

2424
it( 'works for nodes in an iframe', done => {
@@ -27,11 +27,11 @@ describe( 'isDomNode()', () => {
2727
iframe.addEventListener( 'load', () => {
2828
const iframeDocument = iframe.contentWindow.document;
2929

30-
expect( isDomNode( iframeDocument ) ).to.be.true;
31-
expect( isDomNode( iframeDocument.createElement( 'div' ) ) ).to.be.true;
32-
expect( isDomNode( iframeDocument.createTextNode( 'Foo' ) ) ).to.be.true;
30+
expect( isNode( iframeDocument ) ).to.be.true;
31+
expect( isNode( iframeDocument.createElement( 'div' ) ) ).to.be.true;
32+
expect( isNode( iframeDocument.createTextNode( 'Foo' ) ) ).to.be.true;
3333

34-
expect( isDomNode( iframe.contentWindow ) ).to.be.false;
34+
expect( isNode( iframe.contentWindow ) ).to.be.false;
3535

3636
iframe.remove();
3737
done();

0 commit comments

Comments
 (0)