Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'minify-668503'

  • Loading branch information...
commit 2ea8b14b159af76cffd5affbc8f37332e52ee220 2 parents e16bcfb + 0f8e268
@joewalker joewalker authored
View
5 docs/writing-commands.md
@@ -535,7 +535,7 @@ the ``returnValue`` setting.
``returnValue`` processing is currently functioning, but incomplete, and being
tracked in [Bug 657595](http://bugzil.la/657595). Currently you should specify
a ``returnType`` of ``string`` or ``html``. If using HTML, you can return
-either a string for use in processing like ``innerHTML``, or a DOM node.
+either an HTML string or a DOM node.
In the future, JSON will be strongly encouraged as the return type, with some
formatting functions to convert the JSON to HTML.
@@ -559,8 +559,7 @@ and available as input to other commands as a plain string.
...
return "<p>Hello</p>";
-GCLI will interpret this as HTML, and parse it (probably using innerHTML) for
-display.
+GCLI will interpret this as HTML, and parse it for display.
{ returnType: "html" }
...
View
12 lib/gcli/cli.js
@@ -340,7 +340,7 @@ function UnassignedAssignment(requisition, arg) {
name: 'param',
requisition: requisition,
isIncompleteName: (arg.text.charAt(0) === '-')
- },
+ }
});
this.paramIndex = -1;
this.onAssignmentChange = util.createEvent('UnassignedAssignment.onAssignmentChange');
@@ -837,7 +837,7 @@ Requisition.prototype.toCanonicalString = function() {
* to display this typed input. It's a bit like toString on steroids.
* <p>
* The returned object has the following members:<ul>
- * <li>char: The character to which this arg trace refers.
+ * <li>character: The character to which this arg trace refers.
* <li>arg: The Argument to which this character is assigned.
* <li>part: One of ['prefix'|'text'|suffix'] - how was this char understood
* </ul>
@@ -862,13 +862,13 @@ Requisition.prototype.createInputArgTrace = function() {
var i;
this._args.forEach(function(arg) {
for (i = 0; i < arg.prefix.length; i++) {
- args.push({ arg: arg, char: arg.prefix[i], part: 'prefix' });
+ args.push({ arg: arg, character: arg.prefix[i], part: 'prefix' });
}
for (i = 0; i < arg.text.length; i++) {
- args.push({ arg: arg, char: arg.text[i], part: 'text' });
+ args.push({ arg: arg, character: arg.text[i], part: 'text' });
}
for (i = 0; i < arg.suffix.length; i++) {
- args.push({ arg: arg, char: arg.suffix[i], part: 'suffix' });
+ args.push({ arg: arg, character: arg.suffix[i], part: 'suffix' });
}
});
@@ -956,7 +956,7 @@ Requisition.prototype.getInputStatusMarkup = function(cursor) {
}
}
- markup.push({ status: status, string: argTrace.char });
+ markup.push({ status: status, string: argTrace.character });
}
// De-dupe: merge entries where 2 adjacent have same status
View
11 lib/gcli/commands/help.js
@@ -41,7 +41,7 @@ var helpCommandSpec = {
name: 'search',
type: 'string',
description: l10n.lookup('helpSearchDesc'),
- manual: l10n.lookup('helpSearchManual2'),
+ manual: l10n.lookup('helpSearchManual3'),
defaultValue: null
}
],
@@ -126,7 +126,7 @@ function getListTemplateData(args, context) {
ondblclick: function(ev) {
util.executeCommand(ev.currentTarget, context);
- },
+ }
};
}
@@ -146,11 +146,8 @@ function getManTemplateData(command, context) {
util.executeCommand(ev.currentTarget, context);
},
- describe: function(item, element) {
- var text = item.manual || item.description;
- var parent = element.ownerDocument.createElement('div');
- util.setContents(parent, text);
- return parent.childNodes;
+ describe: function(item) {
+ return item.manual || item.description;
},
getTypeDescription: function(param) {
View
4 lib/gcli/commands/help_man.html
@@ -14,7 +14,7 @@ <h4 class="gcli-help-header">
<h4 class="gcli-help-header">${l10n.helpManDescription}:</h4>
- <p class="gcli-help-description">${describe(command, __element)}</p>
+ <p class="gcli-help-description">${describe(command)}</p>
<div if="${command.exec}">
<h4 class="gcli-help-header">${l10n.helpManParameters}:</h4>
@@ -24,7 +24,7 @@ <h4 class="gcli-help-header">${l10n.helpManParameters}:</h4>
<li foreach="param in ${command.params}">
${param.name} <em>${getTypeDescription(param)}</em>
<br/>
- ${describe(param, __element)}
+ ${describe(param)}
</li>
</ul>
</div>
View
2  lib/gcli/commands/pref.js
@@ -93,7 +93,7 @@ var prefSetCmdSpec = {
activate: function() {
context.exec('pref set ' + exports.allowSet.name + ' true');
}
- },
+ }
});
}
args.setting.value = args.value;
View
4 lib/gcli/commands/pref_list.js
@@ -101,7 +101,9 @@ PrefList.prototype.updateTable = function(table) {
data: this
});
var child = view.toDom(table.ownerDocument);
- util.setContents(table, child);
+
+ util.clearElement(table);
+ table.appendChild(child);
};
/**
View
20 lib/gcli/legacy.js
@@ -80,26 +80,6 @@ define(function(require, exports, module) {
}
/**
- * Fake Range.createContextualFragment for IE9
- */
- if (typeof Range.prototype.createContextualFragment === 'undefined') {
- Range.prototype.createContextualFragment = function(html) {
- var container = this.startContainer;
- var doc = container.nodeType == 9 /* i.e. Node.DOCUMENT_NODE */ ?
- container :
- container.ownerDocument;
- var div = doc.createElement('div');
- div.innerHTML = html;
- var frag = doc.createDocumentFragment();
- var n;
- while (n = div.firstChild) {
- frag.appendChild(n);
- }
- return frag;
- };
- }
-
- /**
* String.prototype.trimLeft is non-standard, but it works in Firefox,
* Chrome and Opera. It's easiest to create a shim here.
*/
View
7 lib/gcli/nls/strings.js
@@ -109,15 +109,14 @@ var i18n = {
helpManual: 'Provide help either on a specific command (if a search string is provided and an exact match is found) or on the available commands (if a search string is not provided, or if no exact match is found).',
// A very short description of the 'search' parameter to the 'help' command.
- // See helpSearchManual2 for a fuller description of what it does.
+ // See helpSearchManual3 for a fuller description of what it does.
// This string is designed to be shown in a dialog with restricted space,
// which is why it should be as short as possible.
helpSearchDesc: 'Search string',
// A fuller description of the 'search' parameter to the 'help' command.
- // Displayed when the user asks for help on what it does. Inline HTML
- // (e.g. <strong>) can be used to emphasize the core concept.
- helpSearchManual2: '<strong>search string</strong> to use in narrowing down the displayed commands. Regular expressions not supported.',
+ // Displayed when the user asks for help on what it does.
+ helpSearchManual3: 'search string to use in narrowing down the displayed commands. Regular expressions not supported.',
// A heading shown at the top of a help page for a command in the console
// It labels a summary of the parameters to the command
View
5 lib/gcli/ui/fields.js
@@ -90,10 +90,7 @@ Field.prototype.setMessageElement = function(element) {
*/
Field.prototype.setMessage = function(message) {
if (this.messageElement) {
- if (message == null) {
- message = '';
- }
- util.setContents(this.messageElement, message);
+ util.setTextContent(this.messageElement, message || '');
}
};
View
5 lib/gcli/ui/fields/basic.js
@@ -25,7 +25,6 @@ var TrueNamedArgument = require('gcli/argument').TrueNamedArgument;
var FalseNamedArgument = require('gcli/argument').FalseNamedArgument;
var ArrayArgument = require('gcli/argument').ArrayArgument;
-var Conversion = require('gcli/types').Conversion;
var ArrayConversion = require('gcli/types').ArrayConversion;
var StringType = require('gcli/types/basic').StringType;
@@ -288,7 +287,7 @@ function ArrayField(type, options) {
this.addButton = util.createElement(this.document, 'button');
this.addButton.classList.add('gcli-array-member-add');
this.addButton.addEventListener('click', this._onAdd, false);
- this.addButton.innerHTML = l10n.lookup('fieldArrayAdd');
+ this.addButton.textContent = l10n.lookup('fieldArrayAdd');
this.element.appendChild(this.addButton);
// <div class=gcliArrayMbrs save="${mbrElement}">
@@ -356,7 +355,7 @@ ArrayField.prototype._onAdd = function(ev, subConversion) {
var delButton = util.createElement(this.document, 'button');
delButton.classList.add('gcli-array-member-del');
delButton.addEventListener('click', this._onDel, false);
- delButton.innerHTML = l10n.lookup('fieldArrayDel');
+ delButton.textContent = l10n.lookup('fieldArrayDel');
element.appendChild(delButton);
var member = {
View
2  lib/gcli/ui/fields/selection.js
@@ -113,7 +113,7 @@ SelectionField.prototype._addOption = function(item) {
this.items.push(item);
var option = util.createElement(this.document, 'option');
- option.innerHTML = item.name;
+ option.textContent = item.name;
option.value = item.index;
this.element.appendChild(option);
};
View
2  lib/gcli/ui/focus.js
@@ -37,7 +37,7 @@ var eagerHelperSettingSpec = {
lookup: [
{ name: 'never', value: Eagerness.NEVER },
{ name: 'sometimes', value: Eagerness.SOMETIMES },
- { name: 'always', value: Eagerness.ALWAYS },
+ { name: 'always', value: Eagerness.ALWAYS }
]
},
defaultValue: Eagerness.SOMETIMES,
View
16 lib/gcli/ui/tooltip.js
@@ -222,7 +222,7 @@ Tooltip.prototype.assignmentContentsChanged = function(ev) {
}
this.field.setConversion(ev.conversion);
- util.setContents(this.descriptionEle, this.description);
+ util.setTextContent(this.descriptionEle, this.description);
this._updatePosition();
};
@@ -276,19 +276,7 @@ Object.defineProperty(Tooltip.prototype, 'description', {
return '';
}
- var output = this.assignment.param.manual;
- if (output) {
- var wrapper = this.document.createElement('span');
- util.setContents(wrapper, output);
- if (!this.assignment.param.isDataRequired) {
- var optional = this.document.createElement('span');
- optional.appendChild(this.document.createTextNode(' (Optional)'));
- wrapper.appendChild(optional);
- }
- return wrapper;
- }
-
- return this.assignment.param.description;
+ return this.assignment.param.manual || this.assignment.param.description;
},
enumerable: true
});
View
14 lib/gcli/util.js
@@ -332,14 +332,24 @@ function hash(str) {
return hash;
}
for (var i = 0; i < str.length; i++) {
- var char = str.charCodeAt(i);
- hash = ((hash << 5) - hash) + char;
+ var character = str.charCodeAt(i);
+ hash = ((hash << 5) - hash) + character;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
/**
+ * Shortcut for clearElement/createTextNode/appendChild to make up for the lack
+ * of standards around textContent/innerText
+ */
+exports.setTextContent = function(elem, text) {
+ exports.clearElement(elem);
+ var child = elem.ownerDocument.createTextNode(text);
+ elem.appendChild(child);
+};
+
+/**
* There are problems with innerHTML on XML documents, so we need to do a dance
* using document.createRange().createContextualFragment() when in XML mode
*/
Please sign in to comment.
Something went wrong with that request. Please try again.