[Pkg-javascript-commits] [dojo] 48/149: Fix handling of "${scope}type" property in parser. Fixes #18366. Also refactor parser-args test so it can be debugged independently of Intern.
David Prévot
taffit at moszumanska.debian.org
Sat Feb 27 03:13:46 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository dojo.
commit 8107d124ab2f11b020a5bb87b9dc167c293c1aff
Author: Bill Keese <bill at dojotoolkit.org>
Date: Wed Mar 18 07:32:33 2015 +0900
Fix handling of "${scope}type" property in parser. Fixes #18366.
Also refactor parser-args test so it can be debugged independently of Intern.
---
parser.js | 2 +-
tests/functional/parser/parser-args.html | 44 ++++++++++++++++++++----
tests/functional/parser/parser-args.js | 59 ++++++--------------------------
tests/unit/parser/parser.js | 5 ---
4 files changed, 48 insertions(+), 62 deletions(-)
diff --git a/parser.js b/parser.js
index 0a10338..e33ebb6 100644
--- a/parser.js
+++ b/parser.js
@@ -285,7 +285,7 @@ define([
hash[attrData + "props"] = "data-dojo-props";
hash[attrData + "type"] = "data-dojo-type";
hash[attrData + "mixins"] = "data-dojo-mixins";
- hash[scope + "type"] = "dojoType";
+ hash[scope + "type"] = "dojotype";
hash[attrData + "id"] = "data-dojo-id";
}
diff --git a/tests/functional/parser/parser-args.html b/tests/functional/parser/parser-args.html
index 9b1a6a1..49d4d29 100644
--- a/tests/functional/parser/parser-args.html
+++ b/tests/functional/parser/parser-args.html
@@ -19,22 +19,52 @@
testing: {
dojo: 'testing'
}
- },
- callback: function () {
- ready = true;
}
};
</script>
<script src="../../../dojo.js"></script>
+ <script>
+ require([
+ 'testing/parser',
+ 'dojo/_base/lang',
+ 'dojo/_base/declare',
+ 'dojo/domReady!'
+ ], function (parser, lang, declare) {
+ declare('tests.parser.Class1', null, {
+ constructor: function (args) {
+ this.params = args;
+ lang.mixin(this, args);
+ },
+ strProp1: 'original1',
+ strProp2: 'original2'
+ });
+
+ try {
+ // Test when only the options argument is passed, and it does not contain a rootNode.
+ // For 2.0, if we drop scope parameter, change this test.
+ scopedWidgets = parser.parse({scope: 'myscope'});
+ } catch(err) {
+ // For help in debugging output
+ scopedWidgets = err;
+ }
+ ready = true;
+ });
+ </script>
</head>
<body>
<h1>Parser args Unit Test</h1>
- <div data-myscope-type="tests.parser.Class1" data-myscope-id="scopeObj"
- data-myscope-props="strProp1:'text'">
+ <!-- these should match -->
+ <div data-myscope-type="tests.parser.Class1" data-myscope-id="scopeObj1"
+ data-myscope-props="strProp1:'text1'">
+ </div>
+ <div myscopeType="tests.parser.Class1" data-myscope-id="scopeObj2"
+ data-myscope-props="strProp1:'text2'">
</div>
- <div data-testing-type="tests.parser.Class1" data-testing-id="normalObj"
- data-testing-props="strProp1:'text'">
+
+ <!-- this shouldn't match -->
+ <div data-dojo-type="tests.parser.Class1" data-dojo-id="normalObj"
+ data-dojo-props="strProp1:'text3'">
</div>
</body>
</html>
diff --git a/tests/functional/parser/parser-args.js b/tests/functional/parser/parser-args.js
index e8ed278..9be3fda 100644
--- a/tests/functional/parser/parser-args.js
+++ b/tests/functional/parser/parser-args.js
@@ -7,59 +7,20 @@ define([
registerSuite({
name: 'dojo/parser - arguments',
- test: function () {
+ scope: function () {
var remote = this.get('remote');
return ready(remote, require.toUrl('./parser-args.html'))
- .setExecuteAsyncTimeout(5000)
- .executeAsync(function (done) {
- require([
- 'testing/parser',
- 'dojo/_base/lang',
- 'dojo/_base/declare',
- 'dojo/domReady!'
- ], function (parser, lang, declare) {
- declare('tests.parser.Class1', null, {
- constructor: function (args) {
- this.params = args;
- lang.mixin(this, args);
- },
- strProp1: 'original1',
- strProp2: 'original2'
- });
-
- var widgets = parser.parse();
- done({
- widgetsLength: widgets.length,
- strProp1: widgets[0].strProp1
- });
- });
- })
- .then(function (results) {
+ .execute(function () {
+ var widgets = window.scopedWidgets;
+ return {
+ widgetsLength: widgets.length,
+ strProp1: widgets[0].strProp1 + ", " + widgets[1].strProp1
+ };
+ }).then(function (results) {
assert.deepEqual(results, {
- widgetsLength: 1,
- strProp1: 'text'
+ widgetsLength: 2,
+ strProp1: 'text1, text2'
});
-
- return remote
- .executeAsync(function (done) {
- require([ 'testing/parser' ], function (parser) {
- // Test when only the options argument is passed, and it does not contain a rootNode.
- // For 2.0, if we drop scope parameter, change this test.
- var widgets = parser.parse({
- scope: 'myscope'
- });
- done({
- widgetsLength: widgets.length,
- strProp1: widgets[0].strProp1
- });
- });
- })
- .then(function (results) {
- assert.deepEqual(results, {
- widgetsLength: 1,
- strProp1: 'text'
- });
- });
});
}
});
diff --git a/tests/unit/parser/parser.js b/tests/unit/parser/parser.js
index 4bcac53..f504e56 100644
--- a/tests/unit/parser/parser.js
+++ b/tests/unit/parser/parser.js
@@ -333,11 +333,6 @@ define([
// Make sure that parser doesn't pass any unwanted parameters to
// widget constructor, especially 'toString' or 'constructor'.
// Make exception for dir/lang which parser gleans from document itself.
- //
- // TODO: File a bug about ${scope}[Tt]ype being left in the params in
- // dojo/parser.js. Line 282 in parser.js should alias "dojotype", rather
- // than "dojoType", to "${scope}type"; this would prevent ${scope}[Tt]ype
- // from ending up in the object params.
for (var param in obj.params) {
assert.ok(array.indexOf(
[
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git
More information about the Pkg-javascript-commits
mailing list