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

Two svg compile tests fail in Chrome 54 #15333

Closed
Narretz opened this issue Oct 29, 2016 · 3 comments
Closed

Two svg compile tests fail in Chrome 54 #15333

Narretz opened this issue Oct 29, 2016 · 3 comments

Comments

@Narretz
Copy link
Contributor

Narretz commented Oct 29, 2016

These two tests fail in Chrome 54 and Win 10.

if (supportsForeignObject()) {
it('should handle foreignObject', inject(function() {
element = jqLite('<div><svg-container>' +
'<foreignObject width="100" height="100"><div class="test" style="position:absolute;width:20px;height:20px">test</div></foreignObject>' +
'</svg-container></div>');
$compile(element.contents())($rootScope);
document.body.appendChild(element[0]);
var testElem = element.find('div');
expect(isHTMLElement(testElem[0])).toBe(true);
var bounds = testElem[0].getBoundingClientRect();
expect(bounds.width === 20 && bounds.height === 20).toBe(true);
}));
it('should handle custom svg containers that transclude to foreignObject that transclude html', inject(function() {
element = jqLite('<div><svg-container>' +
'<my-foreign-object><div class="test" style="width:20px;height:20px">test</div></my-foreign-object>' +
'</svg-container></div>');
$compile(element.contents())($rootScope);
document.body.appendChild(element[0]);
var testElem = element.find('div');
expect(isHTMLElement(testElem[0])).toBe(true);
var bounds = testElem[0].getBoundingClientRect();
expect(bounds.width === 20 && bounds.height === 20).toBe(true);
}));

@gkalpak
Copy link
Member

gkalpak commented Oct 29, 2016

👍 I think they started failing on Chrome v53 btw.

@gkalpak
Copy link
Member

gkalpak commented Nov 30, 2016

The reason why they fail is that <foreignObject> elements and their descendants seem to be reported as being 25% larger in each dimension 😕
For example, <foreignObject style="width: 100px; height: 100px;">...</foreignObject>, will be reported as being 125px x 125px by getBoundingClientRect(), although it will have the correct size actually.

gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 30, 2016
…or `<foreignObject>`

Chrome 53-54+ on Windows (only) reports a 25% larger size for `<foreignObject>` elements and their
descendants (although the size is actually correct on the page). For example,
`<foreignObject style="width: 100px; height: 100px;">...</foreignObject>`, will be reported by
`getBoundingClientRect()` as being `125px` x `125px`, although it will be `100px` x `100px` as
expected.

Fixes angular#15333
@gkalpak
Copy link
Member

gkalpak commented Nov 30, 2016

Actually, it doesn't seem to be Windows-specific. I can make it fail on Ubuntu too.
See #15452 (comment).

gkalpak added a commit to gkalpak/angular.js that referenced this issue Dec 1, 2016
…eignObject>`

Since Chrome 53-57+, the reported size of `<foreignObject>` elements and their
descendants is affected by global display settings (e.g. font size) and browser
settings (e.g. default zoom level). This could cause tests incorrectly failing
due to such settings.

In order to avoid false negatives, we now compare against the size of the
equivalent, hand-written SVG instead of fixed widths/heights.

Fixes angular#15333
Narretz pushed a commit to Narretz/angular.js that referenced this issue Dec 1, 2016
…eignObject>`

Since Chrome 53-57+, the reported size of `<foreignObject>` elements and their
descendants is affected by global display settings (e.g. font size) and browser
settings (e.g. default zoom level). This could cause tests incorrectly failing
due to such settings.

In order to avoid false negatives, we now compare against the size of the
equivalent, hand-written SVG instead of fixed widths/heights.

Fixes angular#15333

Closes angular#15458
@gkalpak gkalpak closed this as completed in 9c2d0b8 Dec 1, 2016
gkalpak added a commit that referenced this issue Dec 1, 2016
…eignObject>`

Since Chrome 53-57+, the reported size of `<foreignObject>` elements and their
descendants is affected by global display settings (e.g. font size) and browser
settings (e.g. default zoom level). This could cause tests incorrectly failing
due to such settings.

In order to avoid false negatives, we now compare against the size of the
equivalent, hand-written SVG instead of fixed widths/heights.

Fixes #15333

Closes #15458
ellimist pushed a commit to ellimist/angular.js that referenced this issue Mar 15, 2017
…eignObject>`

Since Chrome 53-57+, the reported size of `<foreignObject>` elements and their
descendants is affected by global display settings (e.g. font size) and browser
settings (e.g. default zoom level). This could cause tests incorrectly failing
due to such settings.

In order to avoid false negatives, we now compare against the size of the
equivalent, hand-written SVG instead of fixed widths/heights.

Fixes angular#15333

Closes angular#15458
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.