Bug 1308467 - fix fronts/css-properties.js when remote debugging old firefox;r=tromey
MozReview-Commit-ID: 365CiBV8uha
--- a/devtools/shared/fronts/css-properties.js
+++ b/devtools/shared/fronts/css-properties.js
@@ -272,38 +272,32 @@ function normalizeCssData(db) {
// now it returns an object with multiple types of CSS information.
if (!db.properties) {
db = { properties: db };
}
// Fill in any missing DB information from the static database.
db = Object.assign({}, CSS_PROPERTIES_DB, db);
- // Add "supports" information to the css properties if it's missing.
- if (!db.properties.color.supports) {
- for (let name in db.properties) {
- if (typeof CSS_PROPERTIES_DB.properties[name] === "object") {
- db.properties[name].supports = CSS_PROPERTIES_DB.properties[name].supports;
- }
+ for (let name in db.properties) {
+ // Skip the current property if we can't find it in CSS_PROPERTIES_DB.
+ if (typeof CSS_PROPERTIES_DB.properties[name] !== "object") {
+ continue;
}
- }
- // Add "values" information to the css properties if it's missing.
- if (!db.properties.color.values) {
- for (let name in db.properties) {
- if (typeof CSS_PROPERTIES_DB.properties[name] === "object") {
- db.properties[name].values = CSS_PROPERTIES_DB.properties[name].values;
- }
+ // Add "supports" information to the css properties if it's missing.
+ if (!db.properties.color.supports) {
+ db.properties[name].supports = CSS_PROPERTIES_DB.properties[name].supports;
}
- }
-
- // Add "subproperties" information to the css properties if it's
- // missing.
- if (!db.properties.background.subproperties) {
- for (let name in db.properties) {
+ // Add "values" information to the css properties if it's missing.
+ if (!db.properties.color.values) {
+ db.properties[name].values = CSS_PROPERTIES_DB.properties[name].values;
+ }
+ // Add "subproperties" information to the css properties if it's missing.
+ if (!db.properties.background.subproperties) {
db.properties[name].subproperties =
CSS_PROPERTIES_DB.properties[name].subproperties;
}
}
}
reattachCssColorValues(db);
@@ -315,17 +309,18 @@ function normalizeCssData(db) {
* @param {Object} The CSS database.
*/
function reattachCssColorValues(db) {
if (db.properties.color.values[0] === "COLOR") {
const colors = Object.keys(cssColors);
for (let name in db.properties) {
const property = db.properties[name];
- if (property.values[0] === "COLOR") {
+ // "values" can be undefined if {name} was not found in CSS_PROPERTIES_DB.
+ if (property.values && property.values[0] === "COLOR") {
property.values.shift();
property.values = property.values.concat(colors).sort();
}
}
}
}
module.exports = {