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

Fixes #204 and #153.#248

Closed
chanon wants to merge 1 commit into
guardian:masterfrom
chanon:master
Closed

Fixes #204 and #153.#248
chanon wants to merge 1 commit into
guardian:masterfrom
chanon:master

Conversation

@chanon
Copy link
Copy Markdown
Contributor

@chanon chanon commented Aug 29, 2014

Makes sure this.range is defined when calling selection.getContaining and selection.placeMarkers. Also makes sure the current selection is inside the scribe element before placing markers. Fixes #204 and #153.

@chanon chanon changed the title Fixes #231 and #153. Fixes #204 and #153. Aug 29, 2014
Makes sure this.range is defined when calling selection.getContaining and selection.placeMarkers. Makes sure the current selection is inside the scribe element before placing markers.
@OliverJAsh
Copy link
Copy Markdown
Contributor

This is a duplicate of #231.

@chanon
Copy link
Copy Markdown
Contributor Author

chanon commented Aug 30, 2014

Yes, the difference is it fixes the issue with less changes to the source and also fixes #153

@hmgibson23
Copy link
Copy Markdown
Contributor

Okay I'm happy to merge this - but in regards to the issues in #231, I think @OliverJAsh might have some opinions about it. Although checking for a range makes sense to me as does checking that we're actually in the scribe.el. The selection does get set if focus is outside the scribe.el - just try selecting the whole page and it happens.

Comment thread src/api/selection.js
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This makes it safer, although I'd also be curious to know what code calls placeMarkers at such a time that this expression is true (i.e. the selection is outside of the Scribe DOM).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here is a reproduction. Just click the Set Content button 10 times and right click + inspect.
http://jsfiddle.net/npqf0Lgu/1/

Since in our use case we need to programmatically update the contents of the scribe, this is what happens (em markers are left around all over the document).

Additional explanation is at end of #153 here: #153 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay - that looks like a good case. I'm happy with this branch if @theefer is. See no reason not to merge this in.

@hmgibson23
Copy link
Copy Markdown
Contributor

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selection#placeMarkers() throws when range is undefined.

5 participants