Bug 1464846 - Font Editor: create new property with desired value instead of initial. r=pbro.
MozReview-Commit-ID: IopuLJQ3NV0
--- a/devtools/client/inspector/fonts/fonts.js
+++ b/devtools/client/inspector/fonts/fonts.js
@@ -198,28 +198,30 @@ class FontInspector {
allFonts = [];
}
return this.excludeNodeFonts(allFonts, nodeFonts);
}
/**
* Get a reference to a TextProperty instance from the current selected rule for a
- * given property name. If one doesn't exist, create and return a new one.
+ * given property name. If one doesn't exist, create one with the given value.
*
* @param {String} name
* CSS property name
+ * @param {String} value
+ * CSS property value
* @return {TextProperty}
*/
- getTextProperty(name) {
+ getTextProperty(name, value) {
if (!this.textProperties.has(name)) {
let textProperty =
this.selectedRule.textProps.find(prop => prop.name === name);
if (!textProperty) {
- textProperty = this.selectedRule.editor.addProperty(name, "initial", "", true);
+ textProperty = this.selectedRule.editor.addProperty(name, value, "", true);
}
this.textProperties.set(name, textProperty);
}
return this.textProperties.get(name);
}
@@ -680,18 +682,18 @@ class FontInspector {
* Preview a property value (live) then sync the changes (throttled) to the Rule view.
*
* @param {String} name
* CSS property name
* @param {String}value
* CSS property value
*/
updatePropertyValue(name, value) {
- const textProperty = this.getTextProperty(name);
- if (!textProperty) {
+ const textProperty = this.getTextProperty(name, value);
+ if (!textProperty || textProperty.value === value) {
return;
}
// Prevent reacting to changes we caused.
this.ruleView.off("property-value-updated", this.onRuleUpdated);
// Live preview font property changes on the page.
textProperty.rule.previewPropertyValue(textProperty, value, "");
// Sync Rule view with changes reflected on the page (throttled).