/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// This file might be required from a node script (./bin/update.js), so don't use // Chrome API here.
if (!targetNode.__compat) { for (const field in targetNode) { // TODO: We don't have a way to know the context for now. // Thus, use first context node as the compat table. // e.g. flex_context of align-item // https://github.com/mdn/browser-compat-data/blob/master/css/properties/align-items.json#L5 if (field.endsWith("_context")) {
targetNode = targetNode[field]; break;
}
}
}
return targetNode.__compat;
}
/** *Returnacompatibilitynodewhichistargetfor`terms`parameterfrom`compatNode` *parameter.Forexample,whencheck`background-clip:content-box;`,the`terms`will *be["background-clip","content-box"].Then,followthenameoftermsfromthe *compatNodenode,returnthetargetnode.Althoughthisfunctionactuallydomore *complexabit,ifitsayssimply,returnsanodeof *compatNode["background-clip"]["content-box""].
*/ function getCompatNode(compatNode, terms) { for (const term of terms) {
compatNode = getChildCompatNode(compatNode, term); if (!compatNode) { returnnull;
}
}
return compatNode;
}
function getChildCompatNode(compatNode, term) {
term = term.toLowerCase();
let child = null; for (const field in compatNode) { if (field.toLowerCase() === term) {
child = compatNode[field]; break;
}
}
if (!child) { returnnull;
}
if (child._aliasOf) { // If the node is an alias, returns the node the alias points.
child = compatNode[child._aliasOf];
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.