8000 Support new CSS `display` syntax by kojiishi · Pull Request #483 · google/budoux · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support new CSS display syntax #483

8000
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

Merged
merged 1 commit into from
Feb 7, 2024
Merged
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
24 changes: 22 additions & 2 deletions javascript/src/html_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,27 @@ const NODETYPE = {
TEXT: 3,
};

/**
* Determine the action for a CSS `display` property value.
* @param display The value of the CSS `display` property.
* @return The {@link domActions} for the value.
*/
function actionForDisplay(display: string): DomAction {
// Handle common cases first.
if (display === 'inline') return DomAction.Inline;
if (display === 'block') return DomAction.Block;

// Handle Ruby base as in-flow.
if (display.startsWith('ruby')) {
if (display === 'ruby-text') return DomAction.Skip;
return DomAction.Inline;
}

// Handle other values including multi-value syntax as blocks.
// https://drafts.csswg.org/css-display/#the-display-properties
return DomAction.Block;
}

/**
* Determine the action for an element.
* @param element An element to determine the action for.
Expand All @@ -182,8 +203,7 @@ function actionForElement(element: Element): DomAction {
}

const display = style.display;
if (display)
return display === 'inline' ? DomAction.Inline : DomAction.Block;
if (display) return actionForDisplay(display);
// `display` is an empty string if the element is not connected.
}

Expand Down
0