Permalink
Browse files

Added rules for NodeList and hasAttr

  • Loading branch information...
1 parent cc796ea commit c6a143a8ff333a1ad2310663177dab69b6d3e9bb @danconn danconn committed Mar 28, 2013
Showing with 21 additions and 1 deletion.
  1. +21 −1 converter.js
View
22 converter.js
@@ -83,6 +83,7 @@ this.CONVERTER = (function () {
'dojo/_base/lang': 'dojoLang',
'dojo/_base/kernel': 'kernel',
'dojo/keys': 'keys',
+ 'dojo/query': 'dojoQuery',
'dojo/_base/event': 'dojoEvent',
'dojo/dom-style': 'domStyle',
'dojo/dom-geometry': 'domGeom',
@@ -168,6 +169,10 @@ this.CONVERTER = (function () {
}
},
{
+ pattern: /dojo\.(has)Attr/g,
+ depend: 'dojo/dom-attr'
+ },
+ {
pattern: /dojo\.(byId)/g,
depend: 'dojo/dom'
},
@@ -273,7 +278,10 @@ this.CONVERTER = (function () {
},
{
pattern: /dojo\.query/g,
- alias: 'dojoQuery',
+ depend: 'dojo/query'
+ },
+ {
+ pattern: /dojo\.(NodeList)/g,
depend: 'dojo/query'
},
{
@@ -715,6 +723,16 @@ this.CONVERTER = (function () {
});
}
+ function normalizeLineEndings(string) {
+ return string.replace(/(?:\r\n?|\n)+/g, "\n");
+ }
+
+ function eliminateWhiteSpace(string) {
+ return string.replace(/[^\S\r\n]+(\r\n?|\n)/g, function (all, ln) {
+ return ln;
+ });
+ }
+
/**
* We use the first argument of the declare signature to get the current "path"
*/
@@ -741,6 +759,8 @@ this.CONVERTER = (function () {
reset();
getCurrentPath(fileString, nsRoot);
fileString = convertDeclare(replaceOldDojo(convertRequires(fileString, currentPath))).trim();
+ fileString = normalizeLineEndings(fileString);
+ fileString = eliminateWhiteSpace(fileString);
this.warnings = warnings;
//hacky workaround for declare, since we only want to replace it at the end
return fileString.replace(/dojo\.declare/g, "declare");

0 comments on commit c6a143a

Please sign in to comment.