jhollingworth/bootstrap-wysihtml5 — pull request #97 by edslocomb (2012-09-04 15:26:50+00:00)
Title: new tests for parserRules, with potential issues

A few unit tests to see that parserRules behave as expected.

Some of these tests fail, in order to illustrate some potential issues.

As currently implemented, when you pass options.parserRules in when you invoke .wysihtml5(), the rules passed in *replace* the default parserRules, rather than extend them. This will probably be unexpected behavior for many users trying to add or modify only a few tags or classes. This is illustrated in the and color class tests.

We could easily change this by using a deep copy in our call to $.extend(), but this would create a new problem; users (developers) would no longer be able to delete properties from the default parserRules. They can be changed, but setting a property's value to false results in different behavior than removing it. This is illustrated with the test; if you change the property in the test options from i: {remove: 1} to i: 0, you will get the same behavior.

I think there are two routes you could take here that make sense; one is to keep the current behavior, and let users know they have to supply a *complete* parserRules, the other is to allow users access to the default parserRules (perhaps by moving the defaults to $.fn.wysihtml5.defaultOptions, or similar)