JSFiddle - React, Tailwind, and code Playground

by ericwilligers

HTML

<div id="report"></div>
<div id="container"></div>

CSS

#report {
  text-align: left
}
#container div {
  animation-duration: 123s;
  animation-timing-function: steps(123);
  animation-delay: -123s;
  animation-iteration-count: 123;
  animation-direction: alternate-reverse;
  animation-fill-mode: backwards;
  animation-play-state: paused;
  animation-name: OneTwoThree;
}

JavaScript

'use strict';
const report = document.getElementById('report');
const container = document.getElementById('container');
const properties = [
	'animation-duration',
  'animation-timing-function',
  'animation-delay',
  'animation-iteration-count',
  'animation-direction',
  'animation-fill-mode',
  'animation-play-state',
  'animation-name',
  'animation',
];

test('animation-delay', '-5s');
test('animation', '-5s');
test('animation-name', 'Forwards');
test('animation', 'Forwards');
test('animation', 'linear ease');

function createElement(parent, tag, textContent) {
  const result = document.createElement(tag);
  parent.appendChild(result);
  if (textContent)
  	result.textContent = textContent;
	return result;
}

function test(property, value) {
  const target = createElement(container, 'div');
  target.style[property] = value;
  
  const section = createElement(report, 'section');
  const heading = createElement(section, 'h3', property + " = '" + value + "'");
  
  const table = createElement(section, 'table');
  {
    const tr = createElement(table, 'tr');
    createElement(tr, 'th', 'Property');
    createElement(tr, 'th', 'Serialized');
    createElement(tr, 'th', 'Computed');
  }
  for (let p of properties) {
    const tr = createElement(table, 'tr');
    createElement(tr, 'td', p);
    createElement(tr, 'td', target.style[p]);
    createElement(tr, 'td', getComputedStyle(target)[p]);
  }
}