Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
"author": "Google Chrome Developers <chromium-dev@google.com>",
"license": "Apache-2.0",
"devDependencies": {
"concurrently": "^3.5.1",
"eslint": "^7.29.0",
"concurrently": "^8.2.1",
"eslint": "^8.48.0",
"eslint-config-developit": "^1.2.0",
"gh-pages": "^1.1.0",
"microbundle": "^0.5.1",
"serve": "^11.3.0",
"transpiler-lite": "gist:781ef9620da8a30228b9f0c6e21fa7f6"
"gh-pages": "^6.0.0",
"microbundle": "^0.15.1",
"serve": "^14.2.1"
},
"dependencies": {
"transpiler-lite": "git+https://gist.github.com/781ef9620da8a30228b9f0c6e21fa7f6.git"
}
}
32 changes: 27 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ if (!CSS.escape) CSS.escape = s => s.replace(/([^\w-])/g,'\\$1');

/** @type {{ [name: string]: { name: string, syntax: string, inherits: boolean, initialValue: string }} } */
const CSS_PROPERTIES = {};
if (!CSS.registerProperty) CSS.registerProperty = function (def) {
let registerPropertyDefault = CSS.registerProperty;
CSS.registerProperty = function (def) {
CSS_PROPERTIES[def.name] = def;
};
if (registerPropertyDefault)
registerPropertyDefault(def);
}

// Minimal poorlyfill for CSS properties+values
function CSSUnitValue(value, unit) {
Expand Down Expand Up @@ -537,7 +540,8 @@ const propertiesContainer = {
// .get() is used by worklets
get(name) {
const def = CSS_PROPERTIES[name];
let v = def && def.inherits === false ? currentElement.style.getPropertyValue(name) : propertiesContainer.getRaw(name);
const computed = getComputedStyle(currentElement);
let v = computed.getPropertyValue(name);
if (v == null && def) v = def.initialValue;
else if (def && def.syntax) {
const s = def.syntax.replace(/[<>\s]/g, '');
Expand Down Expand Up @@ -966,7 +970,7 @@ function init() {
}
}
lock = false;
}).observe(document.body, {
}).observe(document.documentElement, {
childList: true,
attributes: true,
attributeOldValue: true,
Expand Down Expand Up @@ -1080,7 +1084,6 @@ function init() {
'animationstart',
'transitionstart',
'transitionend',
'transitionrun',
'transitioncancel',
'mouseover',
'mouseout',
Expand All @@ -1094,6 +1097,25 @@ function init() {

function updateFromEvent(e) {
let t = e.target;
const type = e.type;
if (type === 'animationstart' || type === 'transitionstart') {
const s = this.$$paintAnimating = (this.$$paintAnimating || 0) + 1;
if (s === 1) {
// Firefox ~68 didn't support Event.path
const p = [];
do { if (t.nodeType === 1) p.push(t); } while ((t = t.parentNode));
let frame = () => {
if (!this.$$paintAnimating) return frame = null;
for (let i=p.length; i--; ) queueUpdate(p[i]);
this.$$paintRaf = (self.requestAnimationFrame || Object)(frame);
};
frame();
}
return;
}
if ((type === 'animationend' || type === 'transitionend' || type === 'transitioncancel') && --this.$$paintAnimating === 0) {
(self.cancelAnimationFrame || Object)(this.$$paintRaf);
}
while (t) {
if (t.nodeType === 1) queueUpdate(t);
t = t.parentNode;
Expand Down