Background style under svg foreign object affects the background of the root viewport |
|||
Issue description
<svg width="100" height="100">
<foreignObject>
<body style="background-color: blue"></body>
</foreignObject>
</svg>
The whole root viewport will be painted blue.
,
Oct 25 2016
> Does the same thing happen if there is more in the SVG than just the foreign object? Yes. > Does it happen if the SVG is within a html doc (I doubt it does). Yes. It happens even if the html doc has <html> and <body> elements (http://jsbin.com/jadame/1). It doesn't happen if the top-level <body> has any non-empty style. http://jsbin.com/jadame/2 is a weirder: the top-level <html> has background which is used to paint the viewport background, but the inner <body>'s background style is used to paint the top-level <body>'s background. This also doesn't happen if the top-level <body> has any non-empty style. After examining the DOM tree and layout tree, I believe this is a parser issue. We don't create Element for the inner <body>, but seem to copy any attribute of the inner <body> to the top-level <body> if the top-level <body> doesn't have the attribute.
,
Oct 26 2016
Yes, this sounds like: https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody case 'A start tag whose tag name is "body"': "Otherwise, ...; then, for each attribute on the token, check to see if the attribute is already present on the body element (the second element) on the stack of open elements, and if it is not, add the attribute and its corresponding value to that element."
,
Oct 26 2016
So, the behavior is expected (to some degree at least), and also shared by FF.
,
Oct 26 2016
Perhaps we should just omit <body> under <forienObject>. |
|||
►
Sign in to add a comment |
|||
Comment 1 by schenney@chromium.org
, Oct 25 2016