Skip to content

Commit

Permalink
Selector bug, discovered from #4
Browse files Browse the repository at this point in the history
  • Loading branch information
SimulatedGREG committed Apr 25, 2016
1 parent f1af903 commit 9c02ceb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 5 additions & 2 deletions dist/kappa.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@
for (var emote in KappaJS.emotes) {
if (KappaJS.emotes.hasOwnProperty(emote)) {
$(self).each(function () {
$(self).html($(self).html().replace(new RegExp('\\b' + emote + '\\b', 'g'), generateImgTag(KappaJS.emotes[emote], emote)));
// NOTE: Transpiler bug
// Next 2 selector should be `this`, but babel grab context of `replaceTextWithEmotes` function
// Manually adjusted in build until futher notice.
$(this).html($(this).html().replace(new RegExp('\\b' + emote + '\\b', 'g'), generateImgTag(KappaJS.emotes[emote], emote)));
});
}
}
Expand All @@ -112,4 +115,4 @@
waitKappaJS();
} else replaceTextWithEmotes();
};
})(jQuery);
})(jQuery);
2 changes: 1 addition & 1 deletion dist/kappa.min.js

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

8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
<title>Kappa.js</title>
</head>
<body>
<div class="kappa">Kappa FailFish WutFace</div>
<div>
<span class="kappa">Kappa</span>
<span class="kappa">FailFish</span>
<span class="kappa">WutFace</span>
</div>

<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="dist/kappa.js"></script>
<script src="dist/kappa.min.js"></script>

<script>
$(document).ready(function() {
Expand Down
3 changes: 3 additions & 0 deletions src/kappa.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
for (var emote in KappaJS.emotes) {
if (KappaJS.emotes.hasOwnProperty(emote)) {
$(self).each(() => {
// NOTE: Transpiler bug
// Next 2 selector should be `this`, but babel grab context of `replaceTextWithEmotes` function
// Manually adjusted in build until futher notice.
$(self).html(
$(self).html().replace(
new RegExp('\\b' + emote + '\\b', 'g'),
Expand Down

0 comments on commit 9c02ceb

Please sign in to comment.