3
Copyright 2012 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
7
if (typeof _yuitest_coverage == "undefined"){
8
_yuitest_coverage = {};
9
_yuitest_coverline = function(src, line){
10
var coverage = _yuitest_coverage[src];
11
if (!coverage.lines[line]){
12
coverage.calledLines++;
14
coverage.lines[line]++;
16
_yuitest_coverfunc = function(src, name, line){
17
var coverage = _yuitest_coverage[src],
18
funcId = name + ":" + line;
19
if (!coverage.functions[funcId]){
20
coverage.calledFunctions++;
22
coverage.functions[funcId]++;
25
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"] = {
32
path: "build/querystring-stringify/querystring-stringify.js",
35
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].code=["YUI.add('querystring-stringify', function (Y, NAME) {","","/**"," * Provides Y.QueryString.stringify method for converting objects to Query Strings."," *"," * @module querystring"," * @submodule querystring-stringify"," * @for QueryString"," * @static"," */","","var QueryString = Y.namespace(\"QueryString\"),"," stack = [],"," L = Y.Lang;","","/**"," * Provides Y.QueryString.escape method to be able to override default encoding"," * method. This is important in cases where non-standard delimiters are used, if"," * the delimiters would not normally be handled properly by the builtin"," * (en|de)codeURIComponent functions."," * Default: encodeURIComponent"," * @module querystring"," * @submodule querystring-stringify"," * @for QueryString"," * @static"," **/","QueryString.escape = encodeURIComponent;","","/**"," * <p>Converts an arbitrary value to a Query String representation.</p>"," *"," * <p>Objects with cyclical references will trigger an exception.</p>"," *"," * @method stringify"," * @public"," * @param obj {Variant} any arbitrary value to convert to query string"," * @param cfg {Object} (optional) Configuration object. The three"," * supported configurations are:"," * <ul><li>sep: When defined, the value will be used as the key-value"," * separator. The default value is \"&\".</li>"," * <li>eq: When defined, the value will be used to join the key to"," * the value. The default value is \"=\".</li>"," * <li>arrayKey: When set to true, the key of an array will have the"," * '[]' notation appended to the key. The default value is false."," * </li></ul>"," * @param name {String} (optional) Name of the current key, for handling children recursively."," * @static"," */","QueryString.stringify = function (obj, c, name) {"," var begin, end, i, l, n, s,"," sep = c && c.sep ? c.sep : \"&\","," eq = c && c.eq ? c.eq : \"=\","," aK = c && c.arrayKey ? c.arrayKey : false;",""," if (L.isNull(obj) || L.isUndefined(obj) || L.isFunction(obj)) {"," return name ? QueryString.escape(name) + eq : '';"," }",""," if (L.isBoolean(obj) || Object.prototype.toString.call(obj) === '[object Boolean]') {"," obj =+ obj;"," }",""," if (L.isNumber(obj) || L.isString(obj)) {"," return QueryString.escape(name) + eq + QueryString.escape(obj);"," }",""," if (L.isArray(obj)) {"," s = [];"," name = aK ? name + '[]' : name;"," l = obj.length;"," for (i = 0; i < l; i++) {"," s.push( QueryString.stringify(obj[i], c, name) );"," }",""," return s.join(sep);"," }"," // now we know it's an object.",""," // Check for cyclical references in nested objects"," for (i = stack.length - 1; i >= 0; --i) {"," if (stack[i] === obj) {"," throw new Error(\"QueryString.stringify. Cyclical reference\");"," }"," }",""," stack.push(obj);"," s = [];"," begin = name ? name + '[' : '';"," end = name ? ']' : '';"," for (i in obj) {"," if (obj.hasOwnProperty(i)) {"," n = begin + i + end;"," s.push(QueryString.stringify(obj[i], c, n));"," }"," }",""," stack.pop();"," s = s.join(sep);"," if (!s && name) {"," return name + \"=\";"," }",""," return s;","};","","","}, '3.7.1', {\"requires\": [\"yui-base\"]});"];
36
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].lines = {"1":0,"12":0,"27":0,"49":0,"50":0,"55":0,"56":0,"59":0,"60":0,"63":0,"64":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"75":0,"80":0,"81":0,"82":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"97":0,"98":0,"99":0,"100":0,"103":0};
37
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].functions = {"stringify:49":0,"(anonymous 1):1":0};
38
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].coveredLines = 34;
39
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].coveredFunctions = 2;
40
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 1);
41
YUI.add('querystring-stringify', function (Y, NAME) {
44
* Provides Y.QueryString.stringify method for converting objects to Query Strings.
47
* @submodule querystring-stringify
52
_yuitest_coverfunc("build/querystring-stringify/querystring-stringify.js", "(anonymous 1)", 1);
53
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 12);
54
var QueryString = Y.namespace("QueryString"),
59
* Provides Y.QueryString.escape method to be able to override default encoding
60
* method. This is important in cases where non-standard delimiters are used, if
61
* the delimiters would not normally be handled properly by the builtin
62
* (en|de)codeURIComponent functions.
63
* Default: encodeURIComponent
65
* @submodule querystring-stringify
69
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 27);
70
QueryString.escape = encodeURIComponent;
73
* <p>Converts an arbitrary value to a Query String representation.</p>
75
* <p>Objects with cyclical references will trigger an exception.</p>
79
* @param obj {Variant} any arbitrary value to convert to query string
80
* @param cfg {Object} (optional) Configuration object. The three
81
* supported configurations are:
82
* <ul><li>sep: When defined, the value will be used as the key-value
83
* separator. The default value is "&".</li>
84
* <li>eq: When defined, the value will be used to join the key to
85
* the value. The default value is "=".</li>
86
* <li>arrayKey: When set to true, the key of an array will have the
87
* '[]' notation appended to the key. The default value is false.
89
* @param name {String} (optional) Name of the current key, for handling children recursively.
92
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 49);
93
QueryString.stringify = function (obj, c, name) {
94
_yuitest_coverfunc("build/querystring-stringify/querystring-stringify.js", "stringify", 49);
95
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 50);
96
var begin, end, i, l, n, s,
97
sep = c && c.sep ? c.sep : "&",
98
eq = c && c.eq ? c.eq : "=",
99
aK = c && c.arrayKey ? c.arrayKey : false;
101
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 55);
102
if (L.isNull(obj) || L.isUndefined(obj) || L.isFunction(obj)) {
103
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 56);
104
return name ? QueryString.escape(name) + eq : '';
107
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 59);
108
if (L.isBoolean(obj) || Object.prototype.toString.call(obj) === '[object Boolean]') {
109
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 60);
113
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 63);
114
if (L.isNumber(obj) || L.isString(obj)) {
115
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 64);
116
return QueryString.escape(name) + eq + QueryString.escape(obj);
119
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 67);
120
if (L.isArray(obj)) {
121
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 68);
123
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 69);
124
name = aK ? name + '[]' : name;
125
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 70);
127
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 71);
128
for (i = 0; i < l; i++) {
129
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 72);
130
s.push( QueryString.stringify(obj[i], c, name) );
133
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 75);
136
// now we know it's an object.
138
// Check for cyclical references in nested objects
139
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 80);
140
for (i = stack.length - 1; i >= 0; --i) {
141
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 81);
142
if (stack[i] === obj) {
143
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 82);
144
throw new Error("QueryString.stringify. Cyclical reference");
148
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 86);
150
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 87);
152
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 88);
153
begin = name ? name + '[' : '';
154
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 89);
155
end = name ? ']' : '';
156
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 90);
158
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 91);
159
if (obj.hasOwnProperty(i)) {
160
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 92);
162
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 93);
163
s.push(QueryString.stringify(obj[i], c, n));
167
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 97);
169
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 98);
171
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 99);
173
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 100);
177
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 103);
182
}, '3.7.1', {"requires": ["yui-base"]});