Skip to content

Commit

Permalink
Ignore duplicates in insertBefore (#1628)
Browse files Browse the repository at this point in the history
Fix #1525 and implement option number 2.
  • Loading branch information
RunDevelopment authored and mAAdhaTTah committed Dec 1, 2018
1 parent 7277591 commit d33d259
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 20 deletions.
10 changes: 5 additions & 5 deletions components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var _ = _self.Prism = {
/**
* Insert a token before another token in a language literal
* As this needs to recreate the object (we cannot actually insert before keys in object literals),
* we cannot just provide an object, we need anobject and a key.
* we cannot just provide an object, we need an object and a key.
* @param inside The key (or language id) of the parent
* @param before The key to insert before.
* @param insert Object with the key/value pairs to insert
Expand All @@ -108,20 +108,20 @@ var _ = _self.Prism = {
var ret = {};

for (var token in grammar) {

if (grammar.hasOwnProperty(token)) {

if (token == before) {

for (var newToken in insert) {

if (insert.hasOwnProperty(newToken)) {
ret[newToken] = insert[newToken];
}
}
}

ret[token] = grammar[token];
// Do not insert token which also occur in insert. See #1525
if (!insert.hasOwnProperty(token)) {
ret[token] = grammar[token];
}
}
}

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.

2 changes: 1 addition & 1 deletion components/prism-csharp.min.js

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

1 change: 0 additions & 1 deletion components/prism-jolie.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Prism.languages.jolie = Prism.languages.extend('clike', {
});

delete Prism.languages.jolie['class-name'];
delete Prism.languages.jolie['function'];

Prism.languages.insertBefore( 'jolie', 'keyword', {
'function':
Expand Down
Loading

0 comments on commit d33d259

Please sign in to comment.