Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If highlighter does not exist, it should throw an error #186

Closed
timdown opened this issue Mar 23, 2014 · 2 comments
Closed

If highlighter does not exist, it should throw an error #186

timdown opened this issue Mar 23, 2014 · 2 comments

Comments

@timdown
Copy link
Owner

timdown commented Mar 23, 2014

From heng...@notable.ac on October 24, 2013 15:30:37

What steps will reproduce the problem? rangy.init();
highlighter = rangy.createHighlighter(document, "TextRange");
highlighter.addClassApplier(rangy.createCssClassApplier("selected-highlighted", {
ignoreWhiteSpace: true,
}));
highlighter.deserialize("type:TextRange|5296$5387$2$some-other-highlighter$"); What is the expected output? What do you see instead? I expect it to use 'selected-highlighted' as the highlighters, or if that's not possible, it should throw an error since 'rangy-highlighter.js' "classApplier = this.classAppliers[parts[3]];" will be undefined. What version of the product are you using? On what operating system? 1.3r751 Please provide any additional information below. I'm on Chrome 30.

Original issue: http://code.google.com/p/rangy/issues/detail?id=186

@timdown
Copy link
Owner Author

timdown commented Mar 23, 2014

From heng...@notable.ac on October 24, 2013 07:40:38

I proposed adding the following code below "classApplier = this.classAppliers[parts[3]];" in deserialize() function:

// If parts[3] highlighter doesn't exist, use whatever is in this.classAppliers
if (typeof classAppliers == 'undefined') {
// Get first object and assign classApplier with it
for(var first_key in this.classAppliers) break;
classApplier = this.classAppliers[first_key];

console.log("Using another classApplier since " + parts[3] + " wasn't added. Using " + first_key + " instead.");

}

@timdown
Copy link
Owner Author

timdown commented Mar 23, 2014

From timd...@gmail.com on December 08, 2013 17:02:00

I agree that something should happen. I prefer the error, otherwise it's slightly non-intuitive behaviour, I think.

I've made the change.

Status: FixedInNextRelease

@timdown timdown closed this as completed Jul 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant