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

map some more features #1792

Merged
merged 1 commit into from
May 28, 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
121 changes: 95 additions & 26 deletions packages/pages/lib/browser-compat/browser-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,39 +129,108 @@ function handleFeature(compat, name, feature) {
return;
}

if (name === 'Element.prototype.inert') {
// skip, deprecated
return true;
}

if (name === 'Event.scrollend') {
if (mapPropertyFeatureAPI(compat, `Element.scrollend_event`, feature.name, feature)) {
return true;
}
}

if (name === 'Event.focusin') {
if (mapPropertyFeatureAPI(compat, `Element.focusin_event`, feature.name, feature)) {
return true;
}
}

if (name === 'Event.hashchange') {
if (mapPropertyFeatureAPI(compat, `Window.hashchange_event`, feature.name, feature)) {
return true;
}
}

if (name === 'MediaQueryList.prototype.addEventListener') {
if (mapPropertyFeatureAPI(compat, `MediaQueryList.EventTarget_inheritance`, feature.name, feature)) {
return true;
}
} else if (name === 'MediaQueryList.prototype.removeEventListener') {
// skip, already handled
return true;
}

if (name === '~custom-elements') {
mapPropertyFeatureAPI(compat, 'Window.customElements', feature.name, feature);
} else if (name.includes('.prototype.')) {
mapPrototypeFeatureAPI(compat, name, feature.name, feature) || mapPrototypeFeatureBuiltin(compat, name, feature.name, feature);
} else if (name.includes('.') && !(name.startsWith('Window.') || name.startsWith('window.')) && !(name.startsWith('Self.') || name.startsWith('self.'))) {
mapStaticPropertyFeatureAPI(compat, name, feature.name, feature) || mapPropertyFeatureAPI(compat, name, feature.name, feature) || mapPropertyFeatureBuiltin(compat, name, feature.name, feature) ||
mapPropertyFeatureAPI(compat, toTitleCase(name), feature.name, feature) || mapPropertyFeatureBuiltin(compat, toTitleCase(name), feature.name, feature);
} else if (bcd.api[name]) {
mapMainFeatureAPI(compat, name, feature.name, feature);
} else if (bcd.javascript.builtins[name]) {
mapMainFeatureBuiltin(compat, name, feature.name, feature);
} else if (bcd.api.Window[name]) {
mapWindowFeatureAPI(compat, name, feature.name, feature)
} else if (bcd.api.WorkerGlobalScope[name]) {
mapWorkerGlobalScopeFeatureAPI(compat, name, feature.name, feature)
} else {
if (name.startsWith('Window.') || name.startsWith('window.')) {
handleFeature(compat, name.substr(7), feature);
return;
if (mapPropertyFeatureAPI(compat, 'Window.customElements', feature.name, feature)) {
return true;
}
}

if (name.includes('.prototype.')) {
if (
mapPrototypeFeatureAPI(compat, name, feature.name, feature) ||
mapPrototypeFeatureBuiltin(compat, name, feature.name, feature)
) {
return true;
}
}

if (name.includes('.') && !(name.startsWith('Window.') || name.startsWith('window.')) && !(name.startsWith('Self.') || name.startsWith('self.'))) {
if (
mapStaticPropertyFeatureAPI(compat, name, feature.name, feature) ||
mapPropertyFeatureAPI(compat, name, feature.name, feature) ||
mapPropertyFeatureBuiltin(compat, name, feature.name, feature) ||
mapPropertyFeatureAPI(compat, toTitleCase(name), feature.name, feature) ||
mapPropertyFeatureBuiltin(compat, toTitleCase(name), feature.name, feature)
) {
return true;
}
}

if (bcd.api[name]) {
if (mapMainFeatureAPI(compat, name, feature.name, feature)) {
return true;
}
}

if (bcd.javascript.builtins[name]) {
if (mapMainFeatureBuiltin(compat, name, feature.name, feature)) {
return true;
}
}

if (bcd.api.Window[name]) {
if (mapWindowFeatureAPI(compat, name, feature.name, feature)) {
return true;
}
}

if (bcd.api.WorkerGlobalScope[name]) {
if (mapWorkerGlobalScopeFeatureAPI(compat, name, feature.name, feature)) {
return true;
}
}

if (name === '~element-qsa-has') {
mapQuerySelectorFeature(compat, `querySelector with :has pseudo class`, feature.name, feature);
return;
if (name.startsWith('Window.') || name.startsWith('window.')) {
if (handleFeature(compat, name.substr(7), feature)) {
return true;
}
}

if (name === '~element-qsa-scope') {
mapQuerySelectorFeature(compat, `querySelector with :scope pseudo class`, feature.name, feature);
return;
if (name === '~element-qsa-has') {
if (mapQuerySelectorFeature(compat, `querySelector with :has pseudo class`, feature.name, feature)) {
return true;
}
}

if (name === '~element-qsa-scope') {
if (mapQuerySelectorFeature(compat, `querySelector with :scope pseudo class`, feature.name, feature)) {
return true;
}
}

console.log('skipped', feature.name);
}
console.log('skipped', feature.name);
}

function mapWindowFeatureAPI(compat, featureName, polyfillName, feature) {
Expand Down