Skip to content

Commit

Permalink
support currentTime attr of audio/video elements
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed May 16, 2021
1 parent 9494bc0 commit 9f81181
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 8 deletions.
197 changes: 195 additions & 2 deletions src/idom/client/app/packages/idom-client-react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"src/**/*.js"
],
"scripts": {
"format": "prettier --print-width 88 --write ./src",
"format": "prettier --write ./src",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
function serializeEvent(event) {
const data = {};
if ("value" in event.target) {
data.value = event.target.value;
}
if (event.type in eventTransforms) {
Object.assign(data, eventTransforms[event.type](event));
}
if (event.target.tagName in targetTransforms) {
Object.assign(data, targetTransforms[event.target.tagName]);
}
return data;
}

const eventCategoryTransforms = {
const targetTransformCategories = {
hasValue: (target) => ({
value: target.value,
}),
hasCurrentTime: (target) => ({
currentTime: target.currentTime,
}),
};

const targetTagCategories = {
hasValue: ["BUTTON", "INPUT", "OPTION", "LI", "METER", "PROGRESS", "PARAM"],
hasCurrentTime: ["AUDIO", "VIDEO"],
};

const targetTransforms = {};

Object.keys(targetTagCategories).forEach((category) => {
targetTagCategories[category].forEach((type) => {
targetTransforms[type] = targetTransformCategories[category];
});
});

const eventTransformCategories = {
clipboard: (event) => ({
clipboardData: event.clipboardData,
}),
Expand Down Expand Up @@ -128,7 +150,7 @@ const eventTransforms = {};

Object.keys(eventTypeCategories).forEach((category) => {
eventTypeCategories[category].forEach((type) => {
eventTransforms[type] = eventCategoryTransforms[category];
eventTransforms[type] = eventTransformCategories[category];
});
});

Expand Down

0 comments on commit 9f81181

Please sign in to comment.