Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Safari does not update grid gap when updated via style property.">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Safari Doesn't Invalidate</title>
</head>
<body>
  <ul class="my-grid" style="grid-gap: 10px">
    <li><img src="https://source.unsplash.com/random/100x100/?nature"></li>
    <li><img src="https://source.unsplash.com/random/100x100/?city"></li>
    <li><img src="https://source.unsplash.com/random/100x100/?safari"></li>
  </ul>
  
  <button onclick="changeGap()">Change Gap</button>
  
  <div id="result">
    <div>
      Current: <span id="result-current"></span>
    </div>
    <div>
      Expected: <span id="result-expected"></span>
    </div>
  </div>
</body>
</html>
 
function changeGap() {
  const grid = document.querySelector('.my-grid');
  const updatedGap = `${Math.floor(Math.random() * 100)}px`;
  grid.style.gridGap = updatedGap;
  updateResults(updatedGap);
}
function updateResults(expectedGap) {
  const result = document.querySelector('#result');
  const grid = document.querySelector('.my-grid');
  const currentGap = grid.style.gap;
  
  result.querySelector('#result-current').innerHTML = currentGap;
  result.querySelector('#result-expected').innerHTML = expectedGap ?? currentGap;
}
updateResults();
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
bfrost2893pro
0viewers