<html>
<head>
<base href="https://bugs.webkit.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - iOS 10.3/Safari 10.1 css background-image in style attribute ignored when using createHTMLDocument method of DOM parsing"
href="https://bugs.webkit.org/show_bug.cgi?id=170285">170285</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>iOS 10.3/Safari 10.1 css background-image in style attribute ignored when using createHTMLDocument method of DOM parsing
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>Safari 10
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>iOS 10
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Blocker
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>HTML DOM
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>martijn+webkitbbug@wirelab.nl
</td>
</tr>
<tr>
<th>CC</th>
<td>cdumez@apple.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=305861" name="attach_305861" title="Simplified proof of concept of the issue.">attachment 305861</a> <a href="attachment.cgi?id=305861&action=edit" title="Simplified proof of concept of the issue.">[details]</a></span>
Simplified proof of concept of the issue.
When parsing a HTML string to DOM elements using DOMImplementation::createHTMLDocument background-images no longer get processed when assigned with inline style attributes. This issue did not exist before iOS 10.3 and/or macOS 10.12.4.
Simple proof of concept:
<!DOCTYPE html>
<html>
<head>
<title>iOS 10.3 / macOS Safari 10.1 - Background image bug POC</title>
<style type="text/css">div { width: 10vw; height: 10vh; background-size: cover; }</style>
</head>
<body>
<script>
var htmlText = '<div style="background-image: url(image.png)"></div>';
var domdoc = document.implementation.createHTMLDocument('template');
domdoc.documentElement.innerHTML = htmlText;
data = domdoc.body.children;
for (var i = 0; i < data.length; i++) document.body.appendChild(data[i]);
</script>
</body>
</html>
Details to the proof of concept:
* The url given in the background-image style property must be a relative or absolute path, NOT a full url.
* The issue occurs on the latest macOS 10.12.4 update for Safari as well as iOS 10.3 Safari.
* When above code is run and network log is inspected you will notice that the image will never get requested.
* When using the webinspector, toggling the background-image style off and back on, the image will be loaded and displayed.
* A workaround at the moment can be found in running a javascript that does: "image.src = image.src", this will result in the image being loaded and displayed.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>