Skip to content

Commit 9c02ceb

Browse files
committed
Selector bug, discovered from #4
1 parent f1af903 commit 9c02ceb

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

dist/kappa.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@
9797
for (var emote in KappaJS.emotes) {
9898
if (KappaJS.emotes.hasOwnProperty(emote)) {
9999
$(self).each(function () {
100-
$(self).html($(self).html().replace(new RegExp('\\b' + emote + '\\b', 'g'), generateImgTag(KappaJS.emotes[emote], emote)));
100+
// NOTE: Transpiler bug
101+
// Next 2 selector should be `this`, but babel grab context of `replaceTextWithEmotes` function
102+
// Manually adjusted in build until futher notice.
103+
$(this).html($(this).html().replace(new RegExp('\\b' + emote + '\\b', 'g'), generateImgTag(KappaJS.emotes[emote], emote)));
101104
});
102105
}
103106
}
@@ -112,4 +115,4 @@
112115
waitKappaJS();
113116
} else replaceTextWithEmotes();
114117
};
115-
})(jQuery);
118+
})(jQuery);

dist/kappa.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
<title>Kappa.js</title>
66
</head>
77
<body>
8-
<div class="kappa">Kappa FailFish WutFace</div>
8+
<div>
9+
<span class="kappa">Kappa</span>
10+
<span class="kappa">FailFish</span>
11+
<span class="kappa">WutFace</span>
12+
</div>
913

1014
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
11-
<script src="dist/kappa.js"></script>
15+
<script src="dist/kappa.min.js"></script>
1216

1317
<script>
1418
$(document).ready(function() {

src/kappa.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@
105105
for (var emote in KappaJS.emotes) {
106106
if (KappaJS.emotes.hasOwnProperty(emote)) {
107107
$(self).each(() => {
108+
// NOTE: Transpiler bug
109+
// Next 2 selector should be `this`, but babel grab context of `replaceTextWithEmotes` function
110+
// Manually adjusted in build until futher notice.
108111
$(self).html(
109112
$(self).html().replace(
110113
new RegExp('\\b' + emote + '\\b', 'g'),

0 commit comments

Comments
 (0)