Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
chore(sortedHtml): print attributes with empty value
Browse files Browse the repository at this point in the history
I had to also fix some tests as they started failing on IE8.

We should figure out why these extra attributes are set in IE8,
but I'm too tired of IE to worry about it now. Since I'm
not introducing this issue just making it visible, I'm going
to commit this as is.
  • Loading branch information
IgorMinar committed Feb 26, 2013
1 parent 753fc9e commit 7ddbde8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,12 +741,16 @@ describe('$compile', function() {
$rootScope.$digest();


expect(sortedHtml(element)).
toEqual('<div><b class="i-hello"></b><span class="i-cau">Cau!</span></div>');
expect(sortedHtml(element)).toBeOneOf(
'<div><b class="i-hello"></b><span class="i-cau">Cau!</span></div>',
'<div><b class="i-hello"></b><span class="i-cau" i-cau="">Cau!</span></div>' //ie8
);

$httpBackend.flush();
expect(sortedHtml(element)).
toEqual('<div><span class="i-hello">Hello!</span><span class="i-cau">Cau!</span></div>');
expect(sortedHtml(element)).toBeOneOf(
'<div><span class="i-hello">Hello!</span><span class="i-cau">Cau!</span></div>',
'<div><span class="i-hello" i-hello="">Hello!</span><span class="i-cau" i-cau="">Cau!</span></div>' //ie8
);
}
));

Expand All @@ -773,8 +777,10 @@ describe('$compile', function() {

$rootScope.$digest();

expect(sortedHtml(element)).
toEqual('<div><span class="i-hello">Hello, Elvis!</span></div>');
expect(sortedHtml(element)).toBeOneOf(
'<div><span class="i-hello">Hello, Elvis!</span></div>',
'<div><span class="i-hello" i-hello="">Hello, Elvis!</span></div>' //ie8
);
}
));

Expand Down Expand Up @@ -803,8 +809,10 @@ describe('$compile', function() {
element = template($rootScope);
$rootScope.$digest();

expect(sortedHtml(element)).
toEqual('<div><span class="i-hello">Hello, Elvis!</span></div>');
expect(sortedHtml(element)).toBeOneOf(
'<div><span class="i-hello">Hello, Elvis!</span></div>',
'<div><span class="i-hello" i-hello="">Hello, Elvis!</span></div>' //ie8
);
}
));

Expand Down Expand Up @@ -1491,13 +1499,13 @@ describe('$compile', function() {
$rootScope.$digest();
expect(sortedHtml(element).replace(' selected="true"', '')).
toEqual('<select ng:model="x">' +
'<option>Greet !</option>' +
'<option value="">Greet !</option>' +
'</select>');
$rootScope.name = 'Misko';
$rootScope.$digest();
expect(sortedHtml(element).replace(' selected="true"', '')).
toEqual('<select ng:model="x">' +
'<option>Greet Misko!</option>' +
'<option value="">Greet Misko!</option>' +
'</select>');
}));

Expand Down
2 changes: 1 addition & 1 deletion test/testabilityPatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function sortedHtml(element, showNgClass) {

var attr = attributes[i];
if(attr.name.match(/^ng[\:\-]/) ||
attr.value &&
(attr.value || attr.value == '') &&
attr.value !='null' &&
attr.value !='auto' &&
attr.value !='false' &&
Expand Down

0 comments on commit 7ddbde8

Please sign in to comment.