-
Notifications
You must be signed in to change notification settings - Fork 64
Fix recursive substitutions, add an option to use the XKCD font, and add mouseovers. #48
base: master
Are you sure you want to change the base?
Conversation
This also will add mouseovers with the original text.
substitutions/js/substitutions.js
Outdated
return; | ||
} | ||
var cls = parent.getAttribute("class"); | ||
if (cls && cls.indexOf("xkcdSubstitutionsExtensionSubbed") != -1) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this would catch the nested terms in #28
We already ignore the immediate children of script, form, etc. elements, as well as spans that we've inserted ourselves. This change makes us skip the entire subtree of such an element. One important effect is that if another extension changes one of our spans using a similar algorithm to ours (inserting a new subtree) we previously could end up reprocessing that node in a future document_end event. Now, we prevent that.
@bencoveney: My original pull request would catch nested terms like #28 describes if we're the only thing mutating the DOM. However, since we can get called multiple times, if another extension changed our subtree, we might end up reprocessing it. I've updated the pull request to account for this. For instance, we substitute "expand" → "physically expand". Suppose that another extension classifies words according to their parts of speech. Now, see how that would play out. We substitute In the code I originally submitted, we only checked the immediate parent to see if it was a span of class I've updated the pull request to prune the entire subtree at the point of |
Use small-caps font-variant to fit in better with text on page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the about page it should be capitalized as xkcd
; in multiple instances you have it as XKCD
I had to rewrite much of the substitution code, but tried to keep the original style. Let me know if there's anything I missed.
This hasn't been heavily tested.