Skip to content
This repository
Browse code

Added rules for NodeList and hasAttr

  • Loading branch information...
commit c6a143a8ff333a1ad2310663177dab69b6d3e9bb 1 parent cc796ea
danconn authored March 28, 2013

Showing 1 changed file with 21 additions and 1 deletion. Show diff stats Hide diff stats

  1. 22  converter.js
22  converter.js
@@ -83,6 +83,7 @@ this.CONVERTER = (function () {
83 83
             'dojo/_base/lang': 'dojoLang',
84 84
             'dojo/_base/kernel': 'kernel',
85 85
             'dojo/keys': 'keys',
  86
+            'dojo/query': 'dojoQuery',
86 87
             'dojo/_base/event': 'dojoEvent',
87 88
             'dojo/dom-style': 'domStyle',
88 89
             'dojo/dom-geometry': 'domGeom',
@@ -168,6 +169,10 @@ this.CONVERTER = (function () {
168 169
                 }
169 170
             },
170 171
             {
  172
+                pattern: /dojo\.(has)Attr/g,
  173
+                depend: 'dojo/dom-attr'
  174
+            },
  175
+            {
171 176
                 pattern: /dojo\.(byId)/g,
172 177
                 depend: 'dojo/dom'
173 178
             },
@@ -273,7 +278,10 @@ this.CONVERTER = (function () {
273 278
             },
274 279
             {
275 280
                 pattern: /dojo\.query/g,
276  
-                alias: 'dojoQuery',
  281
+                depend: 'dojo/query'
  282
+            },
  283
+            {
  284
+                pattern: /dojo\.(NodeList)/g,
277 285
                 depend: 'dojo/query'
278 286
             },
279 287
             {
@@ -715,6 +723,16 @@ this.CONVERTER = (function () {
715 723
         });
716 724
     }
717 725
 
  726
+    function normalizeLineEndings(string) {
  727
+        return string.replace(/(?:\r\n?|\n)+/g, "\n");
  728
+    }
  729
+
  730
+    function eliminateWhiteSpace(string) {
  731
+        return string.replace(/[^\S\r\n]+(\r\n?|\n)/g, function (all, ln) {
  732
+            return ln;
  733
+        });
  734
+    }
  735
+
718 736
     /**
719 737
      * We use the first argument of the declare signature to get the current "path"
720 738
      */
@@ -741,6 +759,8 @@ this.CONVERTER = (function () {
741 759
             reset();
742 760
             getCurrentPath(fileString, nsRoot);
743 761
             fileString = convertDeclare(replaceOldDojo(convertRequires(fileString, currentPath))).trim();
  762
+            fileString = normalizeLineEndings(fileString);
  763
+            fileString = eliminateWhiteSpace(fileString);
744 764
             this.warnings = warnings;
745 765
             //hacky workaround for declare, since we only want to replace it at the end
746 766
             return fileString.replace(/dojo\.declare/g, "declare");

0 notes on commit c6a143a

Please sign in to comment.
Something went wrong with that request. Please try again.