Skip to content

Commit

Permalink
Removed env.elements in 'before-highlightall' hook (#1968)
Browse files Browse the repository at this point in the history
This removes the `env.elements` property from the environment of the `before-highlightall` hook.

**Why?**

- There is no plugin that is using it.
- It is inherently incompatible with `env.selector`. Even if a plugin using `elements` wanted to respect `selector` it would not be able to because 1) there might be plugins after it (in `before-highlightall`) extending the selector and 2) the plugin has no access to the current `container`.

**Isn't this a breaking change?**

Yes, but I don't think that this will have any impact for the above reasons and because from a user perspective, it's hard to use than just iteration over your elements and calling `Prism.highlightElement` yourself.
  • Loading branch information
RunDevelopment authored and mAAdhaTTah committed Jul 11, 2019
1 parent 4a2c90c commit 9d9e2ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ var _ = {
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
};

_.hooks.run("before-highlightall", env);
_.hooks.run('before-highlightall', env);

var elements = env.elements || container.querySelectorAll(env.selector);
var elements = container.querySelectorAll(env.selector);

for (var i=0, element; element = elements[i++];) {
_.highlightElement(element, async === true, env.callback);
Expand Down
2 changes: 1 addition & 1 deletion components/prism-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ var _ = {
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
};

_.hooks.run("before-highlightall", env);
_.hooks.run('before-highlightall', env);

var elements = env.elements || container.querySelectorAll(env.selector);
var elements = container.querySelectorAll(env.selector);

for (var i=0, element; element = elements[i++];) {
_.highlightElement(element, async === true, env.callback);
Expand Down

0 comments on commit 9d9e2ca

Please sign in to comment.