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
Allow filtering mutation executions on user-visibility #764
Allow filtering mutation executions on user-visibility #764
Conversation
} | ||
operationStart = executor.execute(mutationArray, operationStart); | ||
operationStart = executor.execute(mutationArray, operationStart, allow); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of preventing the mutation within each executor, could we stop execution here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, it's not the prettiest... we do need the return value of execute()
for the next start position however.
I also tried adding a new interface method nextPosition(): number
that just returns the next start position:
if (allow) {
operationStart = executor.execute(mutationArray, operationStart);
} else {
operationStart = executor.nextPosition(mutationArray, operationStart);
}
But that resulted in a lot of code duplication for more complex command executors, like here:
worker-dom/src/main-thread/commands/event-subscription.ts
Lines 209 to 217 in b837514
const addEventListenerCount = mutations[startPosition + EventSubscriptionMutationIndex.AddEventListenerCount]; | |
const removeEventListenerCount = mutations[startPosition + EventSubscriptionMutationIndex.RemoveEventListenerCount]; | |
const addEventListenersPosition = | |
startPosition + EventSubscriptionMutationIndex.Events + removeEventListenerCount * REMOVE_EVENT_SUBSCRIPTION_LENGTH; | |
const endPosition = | |
startPosition + | |
EventSubscriptionMutationIndex.Events + | |
addEventListenerCount * ADD_EVENT_SUBSCRIPTION_LENGTH + | |
removeEventListenerCount * REMOVE_EVENT_SUBSCRIPTION_LENGTH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, didnt remember that detail.
Enables enforcement user gesture constraints in use cases like
amp-script
.Context: ampproject/amphtml#26375