Bug 1266826 - Turn Templater.jsm into a .js. r=jryans
authorTom Tromey <ttromey@mozilla.com>
Thu, 12 May 2016 09:06:38 -0600
changeset 336124 be6dbfceb79e570e6859200c2c5a8673f58c277e
parent 336123 666e690baccc847f51b83b223cb29ddf52d5f695
child 336125 b4689ff183ff7e1c342f1997526e9b4cccd64140
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1266826
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1266826 - Turn Templater.jsm into a .js. r=jryans MozReview-Commit-ID: 4T4YiOiU0oZ
.eslintignore
devtools/client/inspector/markup/markup.js
devtools/client/shared/test/browser_templater_basic.js
devtools/shared/gcli/Templater.jsm
devtools/shared/gcli/moz.build
devtools/shared/gcli/source/lib/gcli/util/domtemplate.js
devtools/shared/gcli/templater.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -121,16 +121,17 @@ devtools/server/**
 !devtools/server/actors/styles.js
 devtools/shared/*.js
 !devtools/shared/css-lexer.js
 devtools/shared/*.jsm
 devtools/shared/apps/**
 devtools/shared/client/**
 devtools/shared/discovery/**
 devtools/shared/gcli/**
+!devtools/shared/gcli/templater.js
 devtools/shared/heapsnapshot/**
 devtools/shared/inspector/**
 devtools/shared/layout/**
 devtools/shared/locales/**
 devtools/shared/performance/**
 devtools/shared/qrcode/**
 devtools/shared/security/**
 devtools/shared/shims/**
--- a/devtools/client/inspector/markup/markup.js
+++ b/devtools/client/inspector/markup/markup.js
@@ -40,18 +40,18 @@ const Heritage = require("sdk/core/herit
 const {parseAttribute} =
       require("devtools/client/shared/node-attribute-parser");
 const ELLIPSIS = Services.prefs.getComplexValue("intl.ellipsis",
       Ci.nsIPrefLocalizedString).data;
 const {Task} = require("resource://gre/modules/Task.jsm");
 const {scrollIntoViewIfNeeded} = require("devtools/shared/layout/utils");
 const {PrefObserver} = require("devtools/client/styleeditor/utils");
 const {KeyShortcuts} = require("devtools/client/shared/key-shortcuts");
-
-Cu.import("resource://devtools/shared/gcli/Templater.jsm");
+const {template} = require("devtools/shared/gcli/templater");
+
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 loader.lazyRequireGetter(this, "CSS", "CSS");
 loader.lazyGetter(this, "DOMParser", () => {
   return Cc["@mozilla.org/xmlextras/domparser;1"]
     .createInstance(Ci.nsIDOMParser);
 });
 loader.lazyGetter(this, "AutocompletePopup", () => {
@@ -2554,27 +2554,27 @@ GenericEditor.prototype = {
 /**
  * Creates a simple text editor node, used for TEXT and COMMENT
  * nodes.
  *
  * @param  {MarkupContainer} container
  *         The container owning this editor.
  * @param  {DOMNode} node
  *         The node being edited.
- * @param  {String} template
+ * @param  {String} templateId
  *         The template id to use to build the editor.
  */
-function TextEditor(container, node, template) {
+function TextEditor(container, node, templateId) {
   this.container = container;
   this.markup = this.container.markup;
   this.node = node;
-  this.template = this.markup.template.bind(template);
+  this.template = this.markup.template.bind(templateId);
   this._selected = false;
 
-  this.markup.template(template, this);
+  this.markup.template(templateId, this);
 
   editableField({
     element: this.value,
     stopOnReturn: true,
     trigger: "dblclick",
     multiline: true,
     maxWidth: () => {
       let elementRect = this.value.getBoundingClientRect();
--- a/devtools/client/shared/test/browser_templater_basic.js
+++ b/devtools/client/shared/test/browser_templater_basic.js
@@ -4,17 +4,17 @@
 // Tests that the DOM Template engine works properly
 
 /*
  * These tests run both in Mozilla/Mochitest and plain browsers (as does
  * domtemplate)
  * We should endevour to keep the source in sync.
  */
 
-const template = Cu.import("resource://devtools/shared/gcli/Templater.jsm", {}).template;
+const {template} = require("devtools/shared/gcli/templater");
 
 const TEST_URI = TEST_URI_ROOT + "browser_templater_basic.html";
 
 var test = Task.async(function*() {
   yield addTab("about:blank");
   let [host, win, doc] = yield createHost("bottom", TEST_URI);
 
   info("Starting DOM Templater Tests");
--- a/devtools/shared/gcli/moz.build
+++ b/devtools/shared/gcli/moz.build
@@ -14,10 +14,10 @@ DIRS += [
     'source/lib/gcli/languages',
     'source/lib/gcli/mozui',
     'source/lib/gcli/types',
     'source/lib/gcli/ui',
     'source/lib/gcli/util',
 ]
 
 DevToolsModules(
-    'Templater.jsm'
+    'templater.js'
 )
--- a/devtools/shared/gcli/source/lib/gcli/util/domtemplate.js
+++ b/devtools/shared/gcli/source/lib/gcli/util/domtemplate.js
@@ -11,11 +11,10 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 'use strict';
 
-var Cu = require('chrome').Cu;
-var template = Cu.import('resource://devtools/shared/gcli/Templater.jsm', {}).template;
+var {template} = require("devtools/shared/gcli/templater");
 exports.template = template;
rename from devtools/shared/gcli/Templater.jsm
rename to devtools/shared/gcli/templater.js
--- a/devtools/shared/gcli/Templater.jsm
+++ b/devtools/shared/gcli/templater.js
@@ -13,21 +13,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 "use strict";
 
 /* globals document */
 
-this.EXPORTED_SYMBOLS = [ "template" ];
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "console",
-                                  "resource://gre/modules/Console.jsm");
-
 /**
  * For full documentation, see:
  * https://github.com/mozilla/domtemplate/blob/master/README.md
  */
 
 /**
  * Begin a new templating process.
  * @param node A DOM element or string referring to an element's id
@@ -598,8 +593,10 @@ function handleError(state, message, ex)
 /**
  * A generic way of reporting errors, for easy overloading in different
  * environments.
  * @param message the error message to report.
  */
 function logError(message) {
   console.error(message);
 }
+
+exports.template = template;