Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nested tags, make tests pass #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ rvm:
- 2.2.4
- 2.3.0
before_script:
- wget https://github.com/mozilla/geckodriver/releases/download/v0.16.1/geckodriver-v0.16.1-linux64.tar.gz && tar -xzvf geckodriver-v0.16.1-linux64.tar.gz
- mkdir drivers && mv ./geckodriver drivers/
- export PATH="$PATH:./drivers/"
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
addons:
firefox: "latest"
18 changes: 12 additions & 6 deletions assets/javascripts/i18n_viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ $.fn.enrichWithI18nData = function() {
return $i18n_element;
};

$.fn.clearI18nText = function() {
var $el;
$el = $(this);
$el.textNodes().each(function(index, node) {
node.textContent = node.textContent.replace(I18nViz.global_regex, "");
function clear_i18n(el) {
el.contents().each(function(index, node) {
if (node.nodeType == 3) {
node.textContent = node.textContent.replace(I18nViz.global_regex, "");
} else {
return clear_i18n($(node));
}
});
return $el;
return el;
};

$.fn.clearI18nText = function myself() {
return clear_i18n($(this));
};

$.extend($.expr[':'], {
Expand Down
4 changes: 2 additions & 2 deletions spec/javascripts/i18n_viz_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe "extractI18nKeysFromText()", () ->
it "should return i18n key when 1 present", () ->
expect(window.I18nViz.extractI18nKeysFromText("some text --i18n.key--")).toEqual(["i18n.key"])

it "should return null with no keys present", () ->
it "should return all keys present", () ->
expect(window.I18nViz.extractI18nKeysFromText("some text --i18n.key-- more text --another.key-- end")).toEqual(["i18n.key", "another.key"])

it "should return null with no keys present", () ->
Expand All @@ -24,7 +24,7 @@ describe "jQuery extensions", () ->
expect($jquery_element.text()).toEqual("some text ")

it "should keep child HTML tags", () ->
$jquery_element.append($("<span>some more text --i18n.key2--</span>"))
$jquery_element.append("<span>some more text --i18n.key2--</span>")
$jquery_element.clearI18nText()
expect($jquery_element.text()).toEqual("some text some more text ")
expect($jquery_element.has('span')).toBeTruthy()
Expand Down