Skip to content

Fix IE9 reordering HTML attributes in the key. #158

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

Merged
merged 1 commit into from
Feb 3, 2015
Merged
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
9 changes: 5 additions & 4 deletions dist/angular-gettext.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http",
// IE8 returns UPPER CASE tags, even though the source is lower case.
// This can causes the (key) string in the DOM to have a different case to
// the string in the `po` files.
var test = '<span>test</span>';
var isUpperCaseTags = (angular.element('<span>' + test + '</span>').html() !== test);
// IE9 reorders the attributes of tags.
var test = '<span title="test" class="tested">test</span>';
var isHTMLModified = (angular.element('<span>' + test + '</span>').html() !== test);

var prefixDebug = function (string) {
if (catalog.debug && catalog.currentLanguage !== catalog.baseLanguage) {
Expand Down Expand Up @@ -68,8 +69,8 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http",
for (var key in strings) {
var val = strings[key];

if (isUpperCaseTags) {
// Use the DOM engine to uppercase any tags in the key (#131).
if (isHTMLModified) {
// Use the DOM engine to render any HTML in the key (#131).
key = angular.element('<span>' + key + '</span>').html();
}

Expand Down
2 changes: 1 addition & 1 deletion dist/angular-gettext.min.js

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

9 changes: 5 additions & 4 deletions src/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, $h
// IE8 returns UPPER CASE tags, even though the source is lower case.
// This can causes the (key) string in the DOM to have a different case to
// the string in the `po` files.
var test = '<span>test</span>';
var isUpperCaseTags = (angular.element('<span>' + test + '</span>').html() !== test);
// IE9 reorders the attributes of tags.
var test = '<span title="test" class="tested">test</span>';
var isHTMLModified = (angular.element('<span>' + test + '</span>').html() !== test);

var prefixDebug = function (string) {
if (catalog.debug && catalog.currentLanguage !== catalog.baseLanguage) {
Expand Down Expand Up @@ -56,8 +57,8 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, $h
for (var key in strings) {
var val = strings[key];

if (isUpperCaseTags) {
// Use the DOM engine to uppercase any tags in the key (#131).
if (isHTMLModified) {
// Use the DOM engine to render any HTML in the key (#131).
key = angular.element('<span>' + key + '</span>').html();
}

Expand Down