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

Commit 7ddbde8

Browse files
committed
chore(sortedHtml): print attributes with empty value
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.
1 parent 753fc9e commit 7ddbde8

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

test/ng/compileSpec.js

+18-10
Original file line numberDiff line numberDiff line change
@@ -741,12 +741,16 @@ describe('$compile', function() {
741741
$rootScope.$digest();
742742

743743

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

747749
$httpBackend.flush();
748-
expect(sortedHtml(element)).
749-
toEqual('<div><span class="i-hello">Hello!</span><span class="i-cau">Cau!</span></div>');
750+
expect(sortedHtml(element)).toBeOneOf(
751+
'<div><span class="i-hello">Hello!</span><span class="i-cau">Cau!</span></div>',
752+
'<div><span class="i-hello" i-hello="">Hello!</span><span class="i-cau" i-cau="">Cau!</span></div>' //ie8
753+
);
750754
}
751755
));
752756

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

774778
$rootScope.$digest();
775779

776-
expect(sortedHtml(element)).
777-
toEqual('<div><span class="i-hello">Hello, Elvis!</span></div>');
780+
expect(sortedHtml(element)).toBeOneOf(
781+
'<div><span class="i-hello">Hello, Elvis!</span></div>',
782+
'<div><span class="i-hello" i-hello="">Hello, Elvis!</span></div>' //ie8
783+
);
778784
}
779785
));
780786

@@ -803,8 +809,10 @@ describe('$compile', function() {
803809
element = template($rootScope);
804810
$rootScope.$digest();
805811

806-
expect(sortedHtml(element)).
807-
toEqual('<div><span class="i-hello">Hello, Elvis!</span></div>');
812+
expect(sortedHtml(element)).toBeOneOf(
813+
'<div><span class="i-hello">Hello, Elvis!</span></div>',
814+
'<div><span class="i-hello" i-hello="">Hello, Elvis!</span></div>' //ie8
815+
);
808816
}
809817
));
810818

@@ -1491,13 +1499,13 @@ describe('$compile', function() {
14911499
$rootScope.$digest();
14921500
expect(sortedHtml(element).replace(' selected="true"', '')).
14931501
toEqual('<select ng:model="x">' +
1494-
'<option>Greet !</option>' +
1502+
'<option value="">Greet !</option>' +
14951503
'</select>');
14961504
$rootScope.name = 'Misko';
14971505
$rootScope.$digest();
14981506
expect(sortedHtml(element).replace(' selected="true"', '')).
14991507
toEqual('<select ng:model="x">' +
1500-
'<option>Greet Misko!</option>' +
1508+
'<option value="">Greet Misko!</option>' +
15011509
'</select>');
15021510
}));
15031511

test/testabilityPatch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function sortedHtml(element, showNgClass) {
114114

115115
var attr = attributes[i];
116116
if(attr.name.match(/^ng[\:\-]/) ||
117-
attr.value &&
117+
(attr.value || attr.value == '') &&
118118
attr.value !='null' &&
119119
attr.value !='auto' &&
120120
attr.value !='false' &&

0 commit comments

Comments
 (0)