--- a/devtools/client/inspector/markup/markup.js
+++ b/devtools/client/inspector/markup/markup.js
@@ -593,16 +593,17 @@ MarkupView.prototype = {
evt.preventDefault();
},
/**
* Key handling.
*/
_onKeyDown: function(event) {
let handled = true;
+ let previousNode, nextNode;
// Ignore keystrokes that originated in editors.
if (this._isInputOrTextarea(event.target)) {
return;
}
switch (event.keyCode) {
case Ci.nsIDOMKeyEvent.DOM_VK_H:
@@ -644,49 +645,49 @@ MarkupView.prototype = {
} else {
let next = this._selectionWalker().nextNode();
if (next) {
this.navigate(next.container);
}
}
break;
case Ci.nsIDOMKeyEvent.DOM_VK_UP:
- let prev = this._selectionWalker().previousNode();
- if (prev) {
- this.navigate(prev.container);
+ previousNode = this._selectionWalker().previousNode();
+ if (previousNode) {
+ this.navigate(previousNode.container);
}
break;
case Ci.nsIDOMKeyEvent.DOM_VK_DOWN:
- let next = this._selectionWalker().nextNode();
- if (next) {
- this.navigate(next.container);
+ nextNode = this._selectionWalker().nextNode();
+ if (nextNode) {
+ this.navigate(nextNode.container);
}
break;
case Ci.nsIDOMKeyEvent.DOM_VK_PAGE_UP: {
let walker = this._selectionWalker();
let selection = this._selectedContainer;
for (let i = 0; i < PAGE_SIZE; i++) {
- let prev = walker.previousNode();
- if (!prev) {
+ previousNode = walker.previousNode();
+ if (!previousNode) {
break;
}
- selection = prev.container;
+ selection = previousNode.container;
}
this.navigate(selection);
break;
}
case Ci.nsIDOMKeyEvent.DOM_VK_PAGE_DOWN: {
let walker = this._selectionWalker();
let selection = this._selectedContainer;
for (let i = 0; i < PAGE_SIZE; i++) {
- let next = walker.nextNode();
- if (!next) {
+ nextNode = walker.nextNode();
+ if (!nextNode) {
break;
}
- selection = next.container;
+ selection = nextNode.container;
}
this.navigate(selection);
break;
}
case Ci.nsIDOMKeyEvent.DOM_VK_F2: {
this.beginEditingOuterHTML(this._selectedContainer.node);
break;
}
@@ -950,18 +951,18 @@ MarkupView.prototype = {
} else if (type === "childList") {
// If there has been removals, flash the parent
if (removed.length) {
removedContainers.add(container);
}
// If there has been additions, flash the nodes if their associated
// container exist (so if their parent is expanded in the inspector).
- added.forEach(added => {
- let addedContainer = this.getContainer(added);
+ added.forEach(node => {
+ let addedContainer = this.getContainer(node);
if (addedContainer) {
addedOrEditedContainers.add(addedContainer);
// The node may be added as a result of an append, in which case
// it will have been removed from another container first, but in
// these cases we don't want to flash both the removal and the
// addition
removedContainers.delete(container);
@@ -1496,65 +1497,66 @@ MarkupView.prototype = {
// We're going to issue a children request, make sure it includes the
// centered node.
let centered = this._checkSelectionVisible(container);
// Children aren't updated yet, but clear the childrenDirty flag anyway.
// If the dirty flag is re-set while we're fetching we'll need to fetch
// again.
container.childrenDirty = false;
- let updatePromise = this._getVisibleChildren(container, centered).then(children => {
- if (!this._containers) {
- return promise.reject("markup view destroyed");
- }
- this._queuedChildUpdates.delete(container);
-
- // If children are dirty, we got a change notification for this node
- // while the request was in progress, we need to do it again.
- if (container.childrenDirty) {
- return this._updateChildren(container, {expand: centered});
- }
-
- let fragment = this.doc.createDocumentFragment();
-
- for (let child of children.nodes) {
- let container = this.importNode(child, flash);
- fragment.appendChild(container.elt);
- }
-
- while (container.children.firstChild) {
- container.children.removeChild(container.children.firstChild);
- }
-
- if (!(children.hasFirst && children.hasLast)) {
- let data = {
- showing: this.strings.GetStringFromName("markupView.more.showing"),
- showAll: this.strings.formatStringFromName(
- "markupView.more.showAll",
- [container.node.numChildren.toString()], 1),
- allButtonClick: () => {
- container.maxChildren = -1;
- container.childrenDirty = true;
- this._updateChildren(container);
+ let updatePromise =
+ this._getVisibleChildren(container, centered).then(children => {
+ if (!this._containers) {
+ return promise.reject("markup view destroyed");
+ }
+ this._queuedChildUpdates.delete(container);
+
+ // If children are dirty, we got a change notification for this node
+ // while the request was in progress, we need to do it again.
+ if (container.childrenDirty) {
+ return this._updateChildren(container, {expand: centered});
+ }
+
+ let fragment = this.doc.createDocumentFragment();
+
+ for (let child of children.nodes) {
+ let childContainer = this.importNode(child, flash);
+ fragment.appendChild(childContainer.elt);
+ }
+
+ while (container.children.firstChild) {
+ container.children.removeChild(container.children.firstChild);
+ }
+
+ if (!(children.hasFirst && children.hasLast)) {
+ let data = {
+ showing: this.strings.GetStringFromName("markupView.more.showing"),
+ showAll: this.strings.formatStringFromName(
+ "markupView.more.showAll",
+ [container.node.numChildren.toString()], 1),
+ allButtonClick: () => {
+ container.maxChildren = -1;
+ container.childrenDirty = true;
+ this._updateChildren(container);
+ }
+ };
+
+ if (!children.hasFirst) {
+ let span = this.template("more-nodes", data);
+ fragment.insertBefore(span, fragment.firstChild);
}
- };
-
- if (!children.hasFirst) {
- let span = this.template("more-nodes", data);
- fragment.insertBefore(span, fragment.firstChild);
+ if (!children.hasLast) {
+ let span = this.template("more-nodes", data);
+ fragment.appendChild(span);
+ }
}
- if (!children.hasLast) {
- let span = this.template("more-nodes", data);
- fragment.appendChild(span);
- }
- }
-
- container.children.appendChild(fragment);
- return container;
- }).then(null, console.error);
+
+ container.children.appendChild(fragment);
+ return container;
+ }).then(null, console.error);
this._queuedChildUpdates.set(container, updatePromise);
return updatePromise;
},
_waitForChildren: function() {
if (!this._queuedChildUpdates) {
return promise.resolve(undefined);
}
@@ -2862,31 +2864,31 @@ ElementEditor.prototype = {
let length = editValueDisplayed.length;
let editorLength = editor.input.value.length;
let start = editorLength - (length + 1);
editor.input.setSelectionRange(start, start + length);
} else {
editor.input.select();
}
},
- done: (val, commit, direction) => {
- if (!commit || val === initial) {
+ done: (newValue, commit, direction) => {
+ if (!commit || newValue === initial) {
return;
}
let doMods = this._startModifyingAttributes();
let undoMods = this._startModifyingAttributes();
// Remove the attribute stored in this editor and re-add any attributes
// parsed out of the input element. Restore original attribute if
// parsing fails.
this.refocusOnEdit(attribute.name, attr, direction);
this._saveAttribute(attribute.name, undoMods);
doMods.removeAttribute(attribute.name);
- this._applyAttributes(val, attr, doMods, undoMods);
+ this._applyAttributes(newValue, attr, doMods, undoMods);
this.container.undo.do(() => {
doMods.apply();
}, () => {
undoMods.apply();
});
}
});
@@ -2901,18 +2903,19 @@ ElementEditor.prototype = {
this.removeAttribute(attribute.name);
this.attrElements.set(attribute.name, attr);
// Parse the attribute value to detect whether there are linkable parts in
// it (make sure to pass a complete list of existing attributes to the
// parseAttribute function, by concatenating attribute, because this could
// be a newly added attribute not yet on this.node).
- let attributes = this.node.attributes
- .filter(({name}) => name !== attribute.name);
+ let attributes = this.node.attributes.filter(existingAttribute => {
+ return existingAttribute.name !== attribute.name;
+ });
attributes.push(attribute);
let parsedLinksData = parseAttribute(this.node.namespaceURI,
this.node.tagName, attributes, attribute.name);
// Create links in the attribute value, and collapse long attributes if
// needed.
let collapse = value => {
if (value && value.match(COLLAPSE_DATA_URL_REGEX)) {