From 77888f2b7b619d0b4616071866bebe5d5638dcf1 Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 18 Apr 2017 11:25:03 +0200 Subject: [PATCH 1/6] Implemented Rect#getVisible method. Defined Rect#_obj property. --- src/dom/rect.js | 53 +++++++++++++ tests/dom/rect.js | 191 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+) diff --git a/src/dom/rect.js b/src/dom/rect.js index 92319a4..9a81e55 100644 --- a/src/dom/rect.js +++ b/src/dom/rect.js @@ -40,6 +40,20 @@ export default class Rect { * @param {HTMLElement|Range|ClientRect|module:utils/dom/rect~Rect|Object} obj A source object to create the rect. */ constructor( obj ) { + /** + * The object this rect is for. + * + * @protected + * @readonly + * @member {HTMLElement|Range|ClientRect|module:utils/dom/rect~Rect|Object} #_obj + */ + Object.defineProperty( this, '_obj', { + // obj._obj if already the Rect instance + value: obj._obj || obj, + writable: false, + enumerable: false + } ); + if ( isElement( obj ) || isRange( obj ) ) { obj = obj.getBoundingClientRect(); } @@ -179,6 +193,45 @@ export default class Rect { return this.width * this.height; } + /** + * Returns a new rect, a part of the original rect, which is actually visible to the user, + * e.g. an original rect cropped by parent element rects which have `overflow` set in CSS + * other than `"visible"`. + * + * If there's no such visible rect, which is when the rect is obscured by one or many of + * the ancestors, `null` is returned. + * + * @returns {module:utils/dom/rect~Rect|null} A visible rect instance or `null`, if there's none. + */ + getVisible() { + const obj = this._obj; + let visibleRect = this.clone(); + let parent = obj.parentNode || obj.commonAncestorContainer; + + while ( parent && parent != global.document.body ) { + const parentOverflow = global.window.getComputedStyle( parent ).overflow; + + if ( parentOverflow != 'visible' ) { + const parentRect = new Rect( parent ); + const intersectionRect = visibleRect.getIntersection( parentRect ); + + if ( intersectionRect ) { + if ( intersectionRect.getArea() < visibleRect.getArea() ) { + // Reduce the visible rect to the intersection. + visibleRect = intersectionRect; + } + } else { + // There's no intersection, the rect is completely invisible. + return null; + } + } + + parent = parent.parentNode; + } + + return visibleRect; + } + /** * Returns a rect of the web browser viewport. * diff --git a/tests/dom/rect.js b/tests/dom/rect.js index e20333b..b3718da 100644 --- a/tests/dom/rect.js +++ b/tests/dom/rect.js @@ -26,6 +26,13 @@ describe( 'Rect', () => { } ); describe( 'constructor()', () => { + it( 'should store passed object in #_obj property', () => { + const obj = {}; + const rect = new Rect( obj ); + + expect( rect._obj ).to.equal( obj ); + } ); + it( 'should accept HTMLElement', () => { const element = document.createElement( 'div' ); @@ -97,6 +104,14 @@ describe( 'Rect', () => { expect( clone ).not.equal( rect ); assertRect( clone, rect ); } ); + + it( 'should preserve #_obj', () => { + const rect = new Rect( geometry ); + const clone = rect.clone(); + + expect( clone._obj ).to.equal( rect._obj ); + assertRect( clone, rect ); + } ); } ); describe( 'moveTo()', () => { @@ -320,6 +335,182 @@ describe( 'Rect', () => { } ); } ); + describe( 'getVisible()', () => { + let element, range, ancestorA, ancestorB; + + beforeEach( () => { + element = document.createElement( 'div' ); + range = document.createRange(); + ancestorA = document.createElement( 'div' ); + ancestorB = document.createElement( 'div' ); + + ancestorA.append( element ); + ancestorB.append( ancestorA ); + document.body.appendChild( ancestorB ); + } ); + + afterEach( () => { + ancestorA.remove(); + ancestorB.remove(); + } ); + + it( 'should return a new rect', () => { + const rect = new Rect( {} ); + const visible = rect.getVisible(); + + expect( visible ).to.not.equal( rect ); + } ); + + it( 'should return the visible rect (HTMLElement), partially cropped', () => { + ancestorA.style.overflow = 'scroll'; + + testUtils.sinon.stub( element, 'getBoundingClientRect' ).returns( { + top: 0, + right: 100, + bottom: 100, + left: 0, + width: 100, + height: 100 + } ); + + testUtils.sinon.stub( ancestorA, 'getBoundingClientRect' ).returns( { + top: 50, + right: 150, + bottom: 150, + left: 50, + width: 100, + height: 100 + } ); + + assertRect( new Rect( element ).getVisible(), { + top: 50, + right: 100, + bottom: 100, + left: 50, + width: 50, + height: 50 + } ); + } ); + + it( 'should return the visible rect (HTMLElement), fully visible', () => { + ancestorA.style.overflow = 'scroll'; + + testUtils.sinon.stub( element, 'getBoundingClientRect' ).returns( { + top: 0, + right: 100, + bottom: 100, + left: 0, + width: 100, + height: 100 + } ); + + testUtils.sinon.stub( ancestorA, 'getBoundingClientRect' ).returns( { + top: 0, + right: 150, + bottom: 150, + left: 0, + width: 150, + height: 150 + } ); + + assertRect( new Rect( element ).getVisible(), { + top: 0, + right: 100, + bottom: 100, + left: 0, + width: 100, + height: 100 + } ); + } ); + + it( 'should return the visible rect (HTMLElement), partially cropped, deep ancestor overflow', () => { + ancestorB.style.overflow = 'scroll'; + + testUtils.sinon.stub( element, 'getBoundingClientRect' ).returns( { + top: 0, + right: 100, + bottom: 100, + left: 0, + width: 100, + height: 100 + } ); + + testUtils.sinon.stub( ancestorB, 'getBoundingClientRect' ).returns( { + top: 50, + right: 150, + bottom: 150, + left: 50, + width: 100, + height: 100 + } ); + + assertRect( new Rect( element ).getVisible(), { + top: 50, + right: 100, + bottom: 100, + left: 50, + width: 50, + height: 50 + } ); + } ); + + it( 'should return the visible rect (Range), partially cropped', () => { + range.setStart( ancestorA, 0 ); + ancestorA.style.overflow = 'scroll'; + + testUtils.sinon.stub( range, 'getBoundingClientRect' ).returns( { + top: 0, + right: 100, + bottom: 100, + left: 0, + width: 100, + height: 100 + } ); + + testUtils.sinon.stub( ancestorA, 'getBoundingClientRect' ).returns( { + top: 50, + right: 150, + bottom: 150, + left: 50, + width: 100, + height: 100 + } ); + + assertRect( new Rect( range ).getVisible(), { + top: 50, + right: 100, + bottom: 100, + left: 50, + width: 50, + height: 50 + } ); + } ); + + it( 'should return null if there\'s no visible rect', () => { + ancestorA.style.overflow = 'scroll'; + + testUtils.sinon.stub( element, 'getBoundingClientRect' ).returns( { + top: 0, + right: 100, + bottom: 100, + left: 0, + width: 100, + height: 100 + } ); + + testUtils.sinon.stub( ancestorA, 'getBoundingClientRect' ).returns( { + top: 150, + right: 200, + bottom: 200, + left: 150, + width: 50, + height: 50 + } ); + + expect( new Rect( element ).getVisible() ).to.equal( null ); + } ); + } ); + describe( 'getViewportRect()', () => { it( 'should reaturn a rect', () => { expect( Rect.getViewportRect() ).to.be.instanceOf( Rect ); From ee4b394868c7194bf35d71d034e1595cefa2d67f Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 18 Apr 2017 11:41:04 +0200 Subject: [PATCH 2/6] Fix: The getOptimalPosition utility should consider limiter ancestors with CSS overflow. Closes #148. --- src/dom/position.js | 2 +- tests/dom/position.js | 25 +++++++++++++++++++ tests/manual/tickets/148/1.html | 38 +++++++++++++++++++++++++++++ tests/manual/tickets/148/1.js | 43 +++++++++++++++++++++++++++++++++ tests/manual/tickets/148/1.md | 9 +++++++ 5 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 tests/manual/tickets/148/1.html create mode 100644 tests/manual/tickets/148/1.js create mode 100644 tests/manual/tickets/148/1.md diff --git a/src/dom/position.js b/src/dom/position.js index f9ee7aa..d4a2fad 100644 --- a/src/dom/position.js +++ b/src/dom/position.js @@ -87,7 +87,7 @@ export function getOptimalPosition( { element, target, positions, limiter, fitIn if ( !limiter && !fitInViewport ) { [ name, bestPosition ] = getPosition( positions[ 0 ], targetRect, elementRect ); } else { - const limiterRect = limiter && new Rect( limiter ); + const limiterRect = limiter && new Rect( limiter ).getVisible(); const viewportRect = fitInViewport && Rect.getViewportRect(); [ name, bestPosition ] = diff --git a/tests/dom/position.js b/tests/dom/position.js index 21a9852..35af41e 100644 --- a/tests/dom/position.js +++ b/tests/dom/position.js @@ -159,6 +159,31 @@ describe( 'getOptimalPosition()', () => { name: 'left' } ); } ); + + // https://github.com/ckeditor/ckeditor5-utils/issues/148 + it( 'should return coordinates (#3)', () => { + const overflowedAncestor = getElement( { + top: 100, + left: 0, + bottom: 110, + right: 10, + width: 10, + height: 10 + }, { + overflow: 'scroll' + } ); + + limiter.parentNode = overflowedAncestor; + + assertPosition( { + element, target, limiter, + positions: [ attachRight, attachLeft ] + }, { + top: 100, + left: 10, + name: 'right' + } ); + } ); } ); describe( 'with fitInViewport on', () => { diff --git a/tests/manual/tickets/148/1.html b/tests/manual/tickets/148/1.html new file mode 100644 index 0000000..0d97e60 --- /dev/null +++ b/tests/manual/tickets/148/1.html @@ -0,0 +1,38 @@ +
+
+
+
+ +
+
+ + + diff --git a/tests/manual/tickets/148/1.js b/tests/manual/tickets/148/1.js new file mode 100644 index 0000000..9d66fcf --- /dev/null +++ b/tests/manual/tickets/148/1.js @@ -0,0 +1,43 @@ +/** + * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.md. + */ + +/* global document */ + +import { getOptimalPosition } from '@ckeditor/ckeditor5-utils/src/dom/position'; + +const source = document.querySelector( '.source' ); +const target = document.querySelector( '.target' ); +const limiter = document.querySelector( '.limiter' ); +const positions = { + above: ( targetRect, sourceRect ) => ( { + top: targetRect.top - sourceRect.height - 50, + left: targetRect.left, + name: 'above' + } ), + below: ( targetRect ) => ( { + top: targetRect.bottom + 50, + left: targetRect.left, + name: 'below' + } ) +}; + +function updateSourcePosition() { + const position = getOptimalPosition( { + element: source, + target: target, + positions: [ + positions.above, + positions.below, + ], + limiter: limiter + } ); + + source.style.top = position.top + 'px'; + source.style.left = position.left + 'px'; +} + +updateSourcePosition(); + +document.addEventListener( 'scroll', updateSourcePosition, true ); diff --git a/tests/manual/tickets/148/1.md b/tests/manual/tickets/148/1.md new file mode 100644 index 0000000..652e4ba --- /dev/null +++ b/tests/manual/tickets/148/1.md @@ -0,0 +1,9 @@ +### `getOptimalPosition()` with the `limiter` resticted by overflowed parents [#146](https://github.com/ckeditor/ckeditor5-utils/issues/148) + +Vertically scroll the container up and down. + +**Expected**: + +1. The red square should **always** remain visible regardless of the position of the scroll. +2. In the initial position, the shapes should represent a small letter "i", with the red dot above. +3. In the opposite scroll position, the shapes should represent an exclamation mark "!" with the red dot underneath. From c55ea7efd2507316ab076a8338192af09f44cb9c Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 18 Apr 2017 11:41:49 +0200 Subject: [PATCH 3/6] Tests: Refactoring, moved manual FocusTracker tests to a separate directory. --- tests/manual/{ => focustracker}/focustracker.html | 0 tests/manual/{ => focustracker}/focustracker.js | 2 +- tests/manual/{ => focustracker}/focustracker.md | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename tests/manual/{ => focustracker}/focustracker.html (100%) rename tests/manual/{ => focustracker}/focustracker.js (90%) rename tests/manual/{ => focustracker}/focustracker.md (100%) diff --git a/tests/manual/focustracker.html b/tests/manual/focustracker/focustracker.html similarity index 100% rename from tests/manual/focustracker.html rename to tests/manual/focustracker/focustracker.html diff --git a/tests/manual/focustracker.js b/tests/manual/focustracker/focustracker.js similarity index 90% rename from tests/manual/focustracker.js rename to tests/manual/focustracker/focustracker.js index 084534c..714896f 100644 --- a/tests/manual/focustracker.js +++ b/tests/manual/focustracker/focustracker.js @@ -5,7 +5,7 @@ /* global document */ -import FocusTracker from '../../src/focustracker'; +import FocusTracker from '../../../src/focustracker'; const focusTracker = new FocusTracker(); const counters = document.querySelectorAll( '.status b' ); diff --git a/tests/manual/focustracker.md b/tests/manual/focustracker/focustracker.md similarity index 100% rename from tests/manual/focustracker.md rename to tests/manual/focustracker/focustracker.md From 027d510740cca7119630a35aefe4aef716f0532c Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 18 Apr 2017 15:03:52 +0200 Subject: [PATCH 4/6] Fixed: Range#getVisible throws when used for document#body. --- src/dom/rect.js | 35 ++++++++++++++++++++--------------- tests/dom/rect.js | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/dom/rect.js b/src/dom/rect.js index 9a81e55..bc9976f 100644 --- a/src/dom/rect.js +++ b/src/dom/rect.js @@ -206,27 +206,32 @@ export default class Rect { getVisible() { const obj = this._obj; let visibleRect = this.clone(); - let parent = obj.parentNode || obj.commonAncestorContainer; - while ( parent && parent != global.document.body ) { - const parentOverflow = global.window.getComputedStyle( parent ).overflow; + // There's no ancestor to crop with the overflow. + if ( obj != global.document.body ) { + let parent = obj.parentNode || obj.commonAncestorContainer; - if ( parentOverflow != 'visible' ) { - const parentRect = new Rect( parent ); - const intersectionRect = visibleRect.getIntersection( parentRect ); + // Check the ancestors all the way up to the . + while ( parent && parent != global.document.body ) { + const parentOverflow = global.window.getComputedStyle( parent ).overflow; - if ( intersectionRect ) { - if ( intersectionRect.getArea() < visibleRect.getArea() ) { - // Reduce the visible rect to the intersection. - visibleRect = intersectionRect; + if ( parentOverflow != 'visible' ) { + const parentRect = new Rect( parent ); + const intersectionRect = visibleRect.getIntersection( parentRect ); + + if ( intersectionRect ) { + if ( intersectionRect.getArea() < visibleRect.getArea() ) { + // Reduce the visible rect to the intersection. + visibleRect = intersectionRect; + } + } else { + // There's no intersection, the rect is completely invisible. + return null; } - } else { - // There's no intersection, the rect is completely invisible. - return null; } - } - parent = parent.parentNode; + parent = parent.parentNode; + } } return visibleRect; diff --git a/tests/dom/rect.js b/tests/dom/rect.js index b3718da..49a24a2 100644 --- a/tests/dom/rect.js +++ b/tests/dom/rect.js @@ -361,6 +361,26 @@ describe( 'Rect', () => { expect( visible ).to.not.equal( rect ); } ); + it( 'should not fail when the rect is for document#body', () => { + testUtils.sinon.stub( document.body, 'getBoundingClientRect' ).returns( { + top: 0, + right: 100, + bottom: 100, + left: 0, + width: 100, + height: 100 + } ); + + assertRect( new Rect( document.body ).getVisible(), { + top: 0, + right: 100, + bottom: 100, + left: 0, + width: 100, + height: 100 + } ); + } ); + it( 'should return the visible rect (HTMLElement), partially cropped', () => { ancestorA.style.overflow = 'scroll'; From 24e1d149b0953fa7e63ff92a43e0f6f0ac08da65 Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 18 Apr 2017 17:09:04 +0200 Subject: [PATCH 5/6] Performance: Speed up Rect#getVisible nearly twice by avoiding window#getComputedStyles. --- src/dom/rect.js | 24 ++++++++++-------------- tests/dom/rect.js | 26 ++++++++++++++------------ 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/dom/rect.js b/src/dom/rect.js index bc9976f..867679f 100644 --- a/src/dom/rect.js +++ b/src/dom/rect.js @@ -198,7 +198,7 @@ export default class Rect { * e.g. an original rect cropped by parent element rects which have `overflow` set in CSS * other than `"visible"`. * - * If there's no such visible rect, which is when the rect is obscured by one or many of + * If there's no such visible rect, which is when the rect is limited by one or many of * the ancestors, `null` is returned. * * @returns {module:utils/dom/rect~Rect|null} A visible rect instance or `null`, if there's none. @@ -213,21 +213,17 @@ export default class Rect { // Check the ancestors all the way up to the . while ( parent && parent != global.document.body ) { - const parentOverflow = global.window.getComputedStyle( parent ).overflow; + const parentRect = new Rect( parent ); + const intersectionRect = visibleRect.getIntersection( parentRect ); - if ( parentOverflow != 'visible' ) { - const parentRect = new Rect( parent ); - const intersectionRect = visibleRect.getIntersection( parentRect ); - - if ( intersectionRect ) { - if ( intersectionRect.getArea() < visibleRect.getArea() ) { - // Reduce the visible rect to the intersection. - visibleRect = intersectionRect; - } - } else { - // There's no intersection, the rect is completely invisible. - return null; + if ( intersectionRect ) { + if ( intersectionRect.getArea() < visibleRect.getArea() ) { + // Reduce the visible rect to the intersection. + visibleRect = intersectionRect; } + } else { + // There's no intersection, the rect is completely invisible. + return null; } parent = parent.parentNode; diff --git a/tests/dom/rect.js b/tests/dom/rect.js index 49a24a2..9280bd7 100644 --- a/tests/dom/rect.js +++ b/tests/dom/rect.js @@ -345,8 +345,7 @@ describe( 'Rect', () => { ancestorB = document.createElement( 'div' ); ancestorA.append( element ); - ancestorB.append( ancestorA ); - document.body.appendChild( ancestorB ); + document.body.appendChild( ancestorA ); } ); afterEach( () => { @@ -382,8 +381,6 @@ describe( 'Rect', () => { } ); it( 'should return the visible rect (HTMLElement), partially cropped', () => { - ancestorA.style.overflow = 'scroll'; - testUtils.sinon.stub( element, 'getBoundingClientRect' ).returns( { top: 0, right: 100, @@ -413,8 +410,6 @@ describe( 'Rect', () => { } ); it( 'should return the visible rect (HTMLElement), fully visible', () => { - ancestorA.style.overflow = 'scroll'; - testUtils.sinon.stub( element, 'getBoundingClientRect' ).returns( { top: 0, right: 100, @@ -444,7 +439,8 @@ describe( 'Rect', () => { } ); it( 'should return the visible rect (HTMLElement), partially cropped, deep ancestor overflow', () => { - ancestorB.style.overflow = 'scroll'; + ancestorB.append( ancestorA ); + document.body.appendChild( ancestorB ); testUtils.sinon.stub( element, 'getBoundingClientRect' ).returns( { top: 0, @@ -455,10 +451,19 @@ describe( 'Rect', () => { height: 100 } ); - testUtils.sinon.stub( ancestorB, 'getBoundingClientRect' ).returns( { + testUtils.sinon.stub( ancestorA, 'getBoundingClientRect' ).returns( { top: 50, + right: 100, + bottom: 100, + left: 0, + width: 50, + height: 50 + } ); + + testUtils.sinon.stub( ancestorB, 'getBoundingClientRect' ).returns( { + top: 0, right: 150, - bottom: 150, + bottom: 100, left: 50, width: 100, height: 100 @@ -476,7 +481,6 @@ describe( 'Rect', () => { it( 'should return the visible rect (Range), partially cropped', () => { range.setStart( ancestorA, 0 ); - ancestorA.style.overflow = 'scroll'; testUtils.sinon.stub( range, 'getBoundingClientRect' ).returns( { top: 0, @@ -507,8 +511,6 @@ describe( 'Rect', () => { } ); it( 'should return null if there\'s no visible rect', () => { - ancestorA.style.overflow = 'scroll'; - testUtils.sinon.stub( element, 'getBoundingClientRect' ).returns( { top: 0, right: 100, From 1123afdde3b38a42988124cd36b66311e6e62648 Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Wed, 19 Apr 2017 11:19:52 +0200 Subject: [PATCH 6/6] Renamed Rect#_obj to Rect#_source. Code refactoring. --- src/dom/rect.js | 24 ++++++++++++------------ tests/dom/position.js | 6 +----- tests/dom/rect.js | 8 ++++---- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/dom/rect.js b/src/dom/rect.js index 867679f..40591a5 100644 --- a/src/dom/rect.js +++ b/src/dom/rect.js @@ -37,28 +37,28 @@ export default class Rect { * // Rect out of a ClientRect. * const rectE = new Rect( document.body.getClientRects().item( 0 ) ); * - * @param {HTMLElement|Range|ClientRect|module:utils/dom/rect~Rect|Object} obj A source object to create the rect. + * @param {HTMLElement|Range|ClientRect|module:utils/dom/rect~Rect|Object} source A source object to create the rect. */ - constructor( obj ) { + constructor( source ) { /** * The object this rect is for. * * @protected * @readonly - * @member {HTMLElement|Range|ClientRect|module:utils/dom/rect~Rect|Object} #_obj + * @member {HTMLElement|Range|ClientRect|module:utils/dom/rect~Rect|Object} #_source */ - Object.defineProperty( this, '_obj', { - // obj._obj if already the Rect instance - value: obj._obj || obj, + Object.defineProperty( this, '_source', { + // source._source if already the Rect instance + value: source._source || source, writable: false, enumerable: false } ); - if ( isElement( obj ) || isRange( obj ) ) { - obj = obj.getBoundingClientRect(); + if ( isElement( source ) || isRange( source ) ) { + source = source.getBoundingClientRect(); } - rectProperties.forEach( p => this[ p ] = obj[ p ] ); + rectProperties.forEach( p => this[ p ] = source[ p ] ); /** * The "top" value of the rect. @@ -204,12 +204,12 @@ export default class Rect { * @returns {module:utils/dom/rect~Rect|null} A visible rect instance or `null`, if there's none. */ getVisible() { - const obj = this._obj; + const source = this._source; let visibleRect = this.clone(); // There's no ancestor to crop with the overflow. - if ( obj != global.document.body ) { - let parent = obj.parentNode || obj.commonAncestorContainer; + if ( source != global.document.body ) { + let parent = source.parentNode || source.commonAncestorContainer; // Check the ancestors all the way up to the . while ( parent && parent != global.document.body ) { diff --git a/tests/dom/position.js b/tests/dom/position.js index 35af41e..352c733 100644 --- a/tests/dom/position.js +++ b/tests/dom/position.js @@ -162,19 +162,15 @@ describe( 'getOptimalPosition()', () => { // https://github.com/ckeditor/ckeditor5-utils/issues/148 it( 'should return coordinates (#3)', () => { - const overflowedAncestor = getElement( { + limiter.parentNode = getElement( { top: 100, left: 0, bottom: 110, right: 10, width: 10, height: 10 - }, { - overflow: 'scroll' } ); - limiter.parentNode = overflowedAncestor; - assertPosition( { element, target, limiter, positions: [ attachRight, attachLeft ] diff --git a/tests/dom/rect.js b/tests/dom/rect.js index 9280bd7..b1df5cf 100644 --- a/tests/dom/rect.js +++ b/tests/dom/rect.js @@ -26,11 +26,11 @@ describe( 'Rect', () => { } ); describe( 'constructor()', () => { - it( 'should store passed object in #_obj property', () => { + it( 'should store passed object in #_source property', () => { const obj = {}; const rect = new Rect( obj ); - expect( rect._obj ).to.equal( obj ); + expect( rect._source ).to.equal( obj ); } ); it( 'should accept HTMLElement', () => { @@ -105,11 +105,11 @@ describe( 'Rect', () => { assertRect( clone, rect ); } ); - it( 'should preserve #_obj', () => { + it( 'should preserve #_source', () => { const rect = new Rect( geometry ); const clone = rect.clone(); - expect( clone._obj ).to.equal( rect._obj ); + expect( clone._source ).to.equal( rect._source ); assertRect( clone, rect ); } ); } );