Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support currentTime attr of audio/video elements #369

Merged
merged 2 commits into from
May 16, 2021
Merged
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
2 changes: 1 addition & 1 deletion src/idom/client/app/package-lock.json

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

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.

4 changes: 2 additions & 2 deletions src/idom/client/app/packages/idom-client-react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "idom-client-react",
"description": "A client for IDOM implemented in React",
"version": "0.7.3",
"version": "0.7.4",
"author": "Ryan Morshead",
"license": "MIT",
"repository": {
Expand All @@ -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,41 @@
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));
}

const target = event.target;
if (target.tagName in targetTransforms) {
Object.assign(data, targetTransforms[target.tagName](target));
}

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 +154,7 @@ const eventTransforms = {};

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

Expand Down
2 changes: 2 additions & 0 deletions tests/test_client/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def OldComponent():
with mount_point:
mount_point.mount(OldComponent)
driver.get(mount_point.url())
# ensure the element is displayed before stopping the server
driver.find_element_by_id("old-component")

# the server is disconnected but the last view state is still shown
driver.find_element_by_id("old-component")
Expand Down