Skip to content

Commit

Permalink
Fixed lowercase supposed class names (#1544)
Browse files Browse the repository at this point in the history
This PR fixes a bug with supposed class names.

Lowercase supposed class names are no longer highlighted.

**Before**:
![before](https://user-images.githubusercontent.com/20878432/44656379-e7c17900-a9f8-11e8-8b1a-7f1dd694263e.png)

**After**:
![after](https://user-images.github
usercontent.com/20878432/44656379-e7c17900-a9f8-11e8-8b1a-7f1dd694263e.png)
  • Loading branch information
RunDevelopment authored and mAAdhaTTah committed Aug 28, 2018
1 parent 2b62e57 commit a47c05a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion components/prism-javascript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Prism.languages.javascript = Prism.languages.extend('clike', {
'class-name': [
Prism.languages.clike['class-name'],
/[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/
{
pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
lookbehind: true
}
],
'keyword': [
{
Expand Down
2 changes: 1 addition & 1 deletion components/prism-javascript.min.js

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

5 changes: 4 additions & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,10 @@ Prism.languages.clike = {
Prism.languages.javascript = Prism.languages.extend('clike', {
'class-name': [
Prism.languages.clike['class-name'],
/[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/
{
pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
lookbehind: true
}
],
'keyword': [
{
Expand Down
8 changes: 8 additions & 0 deletions tests/languages/javascript/supposed-classes_feature.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Foo.prototype.bar;
Bar.constructor;
fooBar.prototype.bar;

----------------------------------------------------

Expand All @@ -14,6 +15,13 @@ Bar.constructor;
["class-name", "Bar"],
["punctuation", "."],
"constructor",
["punctuation", ";"],

"\nfooBar",
["punctuation", "."],
"prototype",
["punctuation", "."],
"bar",
["punctuation", ";"]
]

Expand Down

0 comments on commit a47c05a

Please sign in to comment.