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

t/153: Rect utility should work for collapsed DOM Ranges. Closes #153. #154

Merged
merged 2 commits into from
May 4, 2017

Conversation

oleq
Copy link
Member

@oleq oleq commented May 4, 2017

Suggested merge commit message (convention)

Fix: Rect utility should work for collapsed DOM Ranges. Closes ckeditor/ckeditor5#4952.

@oleq oleq requested a review from Reinmar May 4, 2017 11:31
src/dom/rect.js Outdated
//
// @private
// @param {ClientRect|module:utils/dom/rect~Rect|Object} source}
const setProperties = source => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use function definitions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this then? I think it would only complicate the code.

src/dom/rect.js Outdated

rectProperties.forEach( p => this[ p ] = source[ p ] );
if ( isElement( source ) ) {
setProperties( source.getBoundingClientRect() );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like how many times setProperties is executed in this file. Couldn't the rect be assigned to some value and later on the values be set once?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be that way. But since the new case arrived, wherewidth must be set to 0 and the output of getBoundingClientRect/getClientRects is read–only, I would need to use an intermediate object to write client rect's properties to it (in a loop, Object.assign fails) and then alter the witdth, which doesn't look pretty. So I decided this looks better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KK. Makes sense. I didn't now it's read only.

@Reinmar Reinmar merged commit 92aff35 into master May 4, 2017
@Reinmar Reinmar deleted the t/153 branch May 4, 2017 12:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants