From 0eb4c3e7f82e6c60e2f1d0ab56e5883543599d8d Mon Sep 17 00:00:00 2001 From: SimulatedGREG Date: Mon, 25 Apr 2016 16:54:58 -0500 Subject: [PATCH] use jquery given element on $.each() --- bower.json | 2 +- dist/kappa.js | 9 +++------ dist/kappa.min.js | 2 +- package.json | 2 +- src/kappa.js | 9 +++------ 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/bower.json b/bower.json index c77eb57..9ab8da4 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "Kappa.js", - "version": "2.0.0", + "version": "2.0.2", "homepage": "http://simulatedgreg.github.io/kappa.js/", "authors": [ "Greg Holguin " diff --git a/dist/kappa.js b/dist/kappa.js index 4641c9c..08e1bd6 100644 --- a/dist/kappa.js +++ b/dist/kappa.js @@ -96,11 +96,8 @@ function replaceTextWithEmotes() { for (var emote in KappaJS.emotes) { if (KappaJS.emotes.hasOwnProperty(emote)) { - $(self).each(function () { - // 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))); + $(self).each(function (i, el) { + $(el).html($(el).html().replace(new RegExp('\\b' + emote + '\\b', 'g'), generateImgTag(KappaJS.emotes[emote], emote))); }); } } @@ -115,4 +112,4 @@ waitKappaJS(); } else replaceTextWithEmotes(); }; -})(jQuery); +})(jQuery); \ No newline at end of file diff --git a/dist/kappa.min.js b/dist/kappa.min.js index 563b54b..7b64e48 100644 --- a/dist/kappa.min.js +++ b/dist/kappa.min.js @@ -1 +1 @@ -"use strict";!function(e){function a(){return"undefined"!=typeof Storage&&null!==n?!0:new Promise(t)}function t(a,t){e.get("https://twitchemotes.com/api_cache/v2/global.json",function(e){"undefined"!=typeof Storage&&localStorage.setItem("kappa-js",JSON.stringify(e)),a(e)})}var n=localStorage.getItem("kappa-js");null===n?a().then(function(e){window.KappaJS=e}):window.KappaJS=JSON.parse(localStorage.getItem("kappa-js")),e.fn.kappa=function(a){function t(e,a){var t=e.image_id;return[''].join("")}function n(){var e=setInterval(function(){"undefined"!=typeof window.KappaJS&&(o(),clearInterval(e))},500)}function o(){for(var a in KappaJS.emotes)KappaJS.emotes.hasOwnProperty(a)&&e(p).each(function(){e(this).html(e(this).html().replace(new RegExp("\\b"+a+"\\b","g"),t(KappaJS.emotes[a],a)))})}var p=this,i=e.extend({customClass:null,emoteSize:"small"},a);"undefined"==typeof window.KappaJS?n():o()}}(jQuery); +"use strict";!function(e){function a(){return"undefined"!=typeof Storage&&null!==n?!0:new Promise(t)}function t(a,t){e.get("https://twitchemotes.com/api_cache/v2/global.json",function(e){"undefined"!=typeof Storage&&localStorage.setItem("kappa-js",JSON.stringify(e)),a(e)})}var n=localStorage.getItem("kappa-js");null===n?a().then(function(e){window.KappaJS=e}):window.KappaJS=JSON.parse(localStorage.getItem("kappa-js")),e.fn.kappa=function(a){function t(e,a){var t=e.image_id;return[''].join("")}function n(){var e=setInterval(function(){"undefined"!=typeof window.KappaJS&&(o(),clearInterval(e))},500)}function o(){for(var a in KappaJS.emotes)KappaJS.emotes.hasOwnProperty(a)&&e(p).each(function(n,o){e(o).html(e(o).html().replace(new RegExp("\\b"+a+"\\b","g"),t(KappaJS.emotes[a],a)))})}var p=this,i=e.extend({customClass:null,emoteSize:"small"},a);"undefined"==typeof window.KappaJS?n():o()}}(jQuery); \ No newline at end of file diff --git a/package.json b/package.json index 2aa0a1d..8f89572 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kappa.js", - "version": "2.0.0", + "version": "2.0.2", "description": "Kappa.js is a simple jQuery Plugin that can easily find text Twitch emotes and replace them with their respective emoticons. ", "main": "dist/kappa.min.js", "scripts": { diff --git a/src/kappa.js b/src/kappa.js index 62ed706..7fb0a1c 100644 --- a/src/kappa.js +++ b/src/kappa.js @@ -104,12 +104,9 @@ function replaceTextWithEmotes() { 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( + $(self).each((i, el) => { + $(el).html( + $(el).html().replace( new RegExp('\\b' + emote + '\\b', 'g'), generateImgTag(KappaJS.emotes[emote], emote) )