guff-compass 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +21 -0
- data/.gitignore +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/demo/bower_components/jquery/.bower.json +21 -0
- data/demo/bower_components/jquery/.editorconfig +43 -0
- data/demo/bower_components/jquery/.gitattributes +2 -0
- data/demo/bower_components/jquery/.gitignore +14 -0
- data/demo/bower_components/jquery/.gitmodules +6 -0
- data/demo/bower_components/jquery/.jshintrc +17 -0
- data/demo/bower_components/jquery/.mailmap +94 -0
- data/demo/bower_components/jquery/AUTHORS.txt +170 -0
- data/demo/bower_components/jquery/CONTRIBUTING.md +216 -0
- data/demo/bower_components/jquery/Gruntfile.js +594 -0
- data/demo/bower_components/jquery/MIT-LICENSE.txt +21 -0
- data/demo/bower_components/jquery/README.md +398 -0
- data/demo/bower_components/jquery/bower.json +11 -0
- data/demo/bower_components/jquery/build/release-notes.js +59 -0
- data/demo/bower_components/jquery/build/release.js +316 -0
- data/demo/bower_components/jquery/component.json +15 -0
- data/demo/bower_components/jquery/composer.json +35 -0
- data/demo/bower_components/jquery/jquery-migrate.js +511 -0
- data/demo/bower_components/jquery/jquery-migrate.min.js +3 -0
- data/demo/bower_components/jquery/jquery.js +9789 -0
- data/demo/bower_components/jquery/jquery.min.js +6 -0
- data/demo/bower_components/jquery/jquery.min.map +1 -0
- data/demo/bower_components/jquery/package.json +38 -0
- data/demo/bower_components/jquery/speed/benchmark.js +15 -0
- data/demo/bower_components/jquery/speed/benchmarker.css +65 -0
- data/demo/bower_components/jquery/speed/benchmarker.js +181 -0
- data/demo/bower_components/jquery/speed/closest.html +39 -0
- data/demo/bower_components/jquery/speed/css.html +82 -0
- data/demo/bower_components/jquery/speed/event.html +58 -0
- data/demo/bower_components/jquery/speed/filter.html +183 -0
- data/demo/bower_components/jquery/speed/find.html +179 -0
- data/demo/bower_components/jquery/speed/index.html +72 -0
- data/demo/bower_components/jquery/speed/jquery-basis.js +6238 -0
- data/demo/bower_components/jquery/speed/slice.vs.concat.html +47 -0
- data/demo/bower_components/jquery/src/.jshintrc +27 -0
- data/demo/bower_components/jquery/src/ajax.js +855 -0
- data/demo/bower_components/jquery/src/ajax/jsonp.js +80 -0
- data/demo/bower_components/jquery/src/ajax/script.js +86 -0
- data/demo/bower_components/jquery/src/ajax/xhr.js +207 -0
- data/demo/bower_components/jquery/src/attributes.js +659 -0
- data/demo/bower_components/jquery/src/callbacks.js +197 -0
- data/demo/bower_components/jquery/src/core.js +981 -0
- data/demo/bower_components/jquery/src/css.js +661 -0
- data/demo/bower_components/jquery/src/data.js +336 -0
- data/demo/bower_components/jquery/src/deferred.js +141 -0
- data/demo/bower_components/jquery/src/deprecated.js +11 -0
- data/demo/bower_components/jquery/src/dimensions.js +41 -0
- data/demo/bower_components/jquery/src/effects.js +732 -0
- data/demo/bower_components/jquery/src/event-alias.js +32 -0
- data/demo/bower_components/jquery/src/event.js +995 -0
- data/demo/bower_components/jquery/src/exports.js +21 -0
- data/demo/bower_components/jquery/src/intro.js +20 -0
- data/demo/bower_components/jquery/src/manipulation.js +744 -0
- data/demo/bower_components/jquery/src/offset.js +169 -0
- data/demo/bower_components/jquery/src/outro.js +2 -0
- data/demo/bower_components/jquery/src/queue.js +146 -0
- data/demo/bower_components/jquery/src/serialize.js +99 -0
- data/demo/bower_components/jquery/src/sizzle-jquery.js +7 -0
- data/demo/bower_components/jquery/src/support.js +246 -0
- data/demo/bower_components/jquery/src/traversing.js +283 -0
- data/demo/bower_components/jquery/src/wrap.js +66 -0
- data/demo/bower_components/jquery/test/.jshintignore +3 -0
- data/demo/bower_components/jquery/test/.jshintrc +60 -0
- data/demo/bower_components/jquery/test/data/1x1.jpg +0 -0
- data/demo/bower_components/jquery/test/data/ajax/unreleasedXHR.html +25 -0
- data/demo/bower_components/jquery/test/data/atom+xml.php +4 -0
- data/demo/bower_components/jquery/test/data/badcall.js +1 -0
- data/demo/bower_components/jquery/test/data/badjson.js +1 -0
- data/demo/bower_components/jquery/test/data/cleanScript.html +10 -0
- data/demo/bower_components/jquery/test/data/core/cc_on.html +22 -0
- data/demo/bower_components/jquery/test/data/dashboard.xml +11 -0
- data/demo/bower_components/jquery/test/data/dimensions/documentLarge.html +17 -0
- data/demo/bower_components/jquery/test/data/dimensions/documentSmall.html +21 -0
- data/demo/bower_components/jquery/test/data/echoData.php +1 -0
- data/demo/bower_components/jquery/test/data/echoQuery.php +1 -0
- data/demo/bower_components/jquery/test/data/errorWithJSON.php +6 -0
- data/demo/bower_components/jquery/test/data/errorWithText.php +5 -0
- data/demo/bower_components/jquery/test/data/etag.php +21 -0
- data/demo/bower_components/jquery/test/data/evalScript.php +1 -0
- data/demo/bower_components/jquery/test/data/event/focusElem.html +16 -0
- data/demo/bower_components/jquery/test/data/event/longLoadScript.php +4 -0
- data/demo/bower_components/jquery/test/data/event/promiseReady.html +17 -0
- data/demo/bower_components/jquery/test/data/event/syncReady.html +23 -0
- data/demo/bower_components/jquery/test/data/headers.php +18 -0
- data/demo/bower_components/jquery/test/data/if_modified_since.php +20 -0
- data/demo/bower_components/jquery/test/data/iframe.html +8 -0
- data/demo/bower_components/jquery/test/data/jquery-1.9.1.ajax_xhr.min.js +5 -0
- data/demo/bower_components/jquery/test/data/json.php +13 -0
- data/demo/bower_components/jquery/test/data/json_obj.js +1 -0
- data/demo/bower_components/jquery/test/data/jsonp.php +14 -0
- data/demo/bower_components/jquery/test/data/manipulation/iframe-denied.html +36 -0
- data/demo/bower_components/jquery/test/data/name.html +1 -0
- data/demo/bower_components/jquery/test/data/name.php +24 -0
- data/demo/bower_components/jquery/test/data/nocontent.php +5 -0
- data/demo/bower_components/jquery/test/data/offset/absolute.html +41 -0
- data/demo/bower_components/jquery/test/data/offset/body.html +26 -0
- data/demo/bower_components/jquery/test/data/offset/fixed.html +34 -0
- data/demo/bower_components/jquery/test/data/offset/relative.html +31 -0
- data/demo/bower_components/jquery/test/data/offset/scroll.html +39 -0
- data/demo/bower_components/jquery/test/data/offset/static.html +31 -0
- data/demo/bower_components/jquery/test/data/offset/table.html +43 -0
- data/demo/bower_components/jquery/test/data/params_html.php +12 -0
- data/demo/bower_components/jquery/test/data/readywaitasset.js +1 -0
- data/demo/bower_components/jquery/test/data/readywaitloader.js +25 -0
- data/demo/bower_components/jquery/test/data/script.php +11 -0
- data/demo/bower_components/jquery/test/data/selector/html5_selector.html +114 -0
- data/demo/bower_components/jquery/test/data/selector/sizzle_cache.html +21 -0
- data/demo/bower_components/jquery/test/data/statusText.php +5 -0
- data/demo/bower_components/jquery/test/data/support/bodyBackground.html +28 -0
- data/demo/bower_components/jquery/test/data/support/boxSizing.html +19 -0
- data/demo/bower_components/jquery/test/data/support/csp.js +3 -0
- data/demo/bower_components/jquery/test/data/support/csp.php +22 -0
- data/demo/bower_components/jquery/test/data/support/shrinkWrapBlocks.html +23 -0
- data/demo/bower_components/jquery/test/data/support/testElementCrash.html +17 -0
- data/demo/bower_components/jquery/test/data/test.html +7 -0
- data/demo/bower_components/jquery/test/data/test.js +3 -0
- data/demo/bower_components/jquery/test/data/test.php +7 -0
- data/demo/bower_components/jquery/test/data/test2.html +5 -0
- data/demo/bower_components/jquery/test/data/test3.html +3 -0
- data/demo/bower_components/jquery/test/data/testinit.js +264 -0
- data/demo/bower_components/jquery/test/data/testrunner.js +371 -0
- data/demo/bower_components/jquery/test/data/testsuite.css +155 -0
- data/demo/bower_components/jquery/test/data/text.php +12 -0
- data/demo/bower_components/jquery/test/data/ua.txt +272 -0
- data/demo/bower_components/jquery/test/data/with_fries.xml +25 -0
- data/demo/bower_components/jquery/test/data/with_fries_over_jsonp.php +7 -0
- data/demo/bower_components/jquery/test/delegatetest.html +228 -0
- data/demo/bower_components/jquery/test/hovertest.html +158 -0
- data/demo/bower_components/jquery/test/index.html +337 -0
- data/demo/bower_components/jquery/test/jquery.js +5 -0
- data/demo/bower_components/jquery/test/localfile.html +75 -0
- data/demo/bower_components/jquery/test/networkerror.html +84 -0
- data/demo/bower_components/jquery/test/readywait.html +70 -0
- data/demo/bower_components/jquery/test/unit/ajax.js +2016 -0
- data/demo/bower_components/jquery/test/unit/attributes.js +1388 -0
- data/demo/bower_components/jquery/test/unit/callbacks.js +342 -0
- data/demo/bower_components/jquery/test/unit/core.js +1360 -0
- data/demo/bower_components/jquery/test/unit/css.js +1056 -0
- data/demo/bower_components/jquery/test/unit/data.js +645 -0
- data/demo/bower_components/jquery/test/unit/deferred.js +436 -0
- data/demo/bower_components/jquery/test/unit/deprecated.js +8 -0
- data/demo/bower_components/jquery/test/unit/dimensions.js +472 -0
- data/demo/bower_components/jquery/test/unit/effects.js +2242 -0
- data/demo/bower_components/jquery/test/unit/event.js +2755 -0
- data/demo/bower_components/jquery/test/unit/exports.js +7 -0
- data/demo/bower_components/jquery/test/unit/manipulation.js +2120 -0
- data/demo/bower_components/jquery/test/unit/offset.js +559 -0
- data/demo/bower_components/jquery/test/unit/queue.js +314 -0
- data/demo/bower_components/jquery/test/unit/selector.js +172 -0
- data/demo/bower_components/jquery/test/unit/serialize.js +148 -0
- data/demo/bower_components/jquery/test/unit/support.js +370 -0
- data/demo/bower_components/jquery/test/unit/traversing.js +797 -0
- data/demo/bower_components/jquery/test/unit/wrap.js +265 -0
- data/demo/bower_components/jquery/test/xhtml.php +5 -0
- data/demo/index.html +347 -0
- data/demo/styles/main.css +208 -0
- data/demo/styles/main.scss +138 -0
- data/docs/docco.css +506 -0
- data/docs/guff.html +1127 -0
- data/docs/public/fonts/aller-bold.eot +0 -0
- data/docs/public/fonts/aller-bold.ttf +0 -0
- data/docs/public/fonts/aller-bold.woff +0 -0
- data/docs/public/fonts/aller-light.eot +0 -0
- data/docs/public/fonts/aller-light.ttf +0 -0
- data/docs/public/fonts/aller-light.woff +0 -0
- data/docs/public/fonts/novecento-bold.eot +0 -0
- data/docs/public/fonts/novecento-bold.ttf +0 -0
- data/docs/public/fonts/novecento-bold.woff +0 -0
- data/docs/public/stylesheets/normalize.css +375 -0
- data/guff.gemspec +16 -0
- data/guff.scss +514 -0
- data/gulpfile.js +67 -0
- data/lib/guff.rb +4 -0
- data/lib/stylesheets/_guff.scss +514 -0
- data/package.json +19 -0
- data/src/_functions.scss +57 -0
- data/src/_mixins.scss +301 -0
- data/src/_reset.scss +67 -0
- data/src/_settings.scss +22 -0
- data/src/_typography.scss +67 -0
- metadata +259 -0
@@ -0,0 +1,645 @@
|
|
1
|
+
module("data", { teardown: moduleTeardown });
|
2
|
+
|
3
|
+
test("expando", function(){
|
4
|
+
expect(1);
|
5
|
+
|
6
|
+
equal(jQuery.expando !== undefined, true, "jQuery is exposing the expando");
|
7
|
+
});
|
8
|
+
|
9
|
+
function dataTests (elem) {
|
10
|
+
var dataObj, internalDataObj;
|
11
|
+
|
12
|
+
equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" );
|
13
|
+
strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" );
|
14
|
+
|
15
|
+
dataObj = jQuery.data(elem);
|
16
|
+
equal( typeof dataObj, "object", "Calling data with no args gives us a data object reference" );
|
17
|
+
strictEqual( jQuery.data(elem), dataObj, "Calling jQuery.data returns the same data object when called multiple times" );
|
18
|
+
|
19
|
+
strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" );
|
20
|
+
|
21
|
+
dataObj["foo"] = "bar";
|
22
|
+
equal( jQuery.data(elem, "foo"), "bar", "Data is readable by jQuery.data when set directly on a returned data object" );
|
23
|
+
|
24
|
+
strictEqual( jQuery.hasData(elem), true, "jQuery.hasData agrees data exists when data exists" );
|
25
|
+
|
26
|
+
jQuery.data(elem, "foo", "baz");
|
27
|
+
equal( jQuery.data(elem, "foo"), "baz", "Data can be changed by jQuery.data" );
|
28
|
+
equal( dataObj["foo"], "baz", "Changes made through jQuery.data propagate to referenced data object" );
|
29
|
+
|
30
|
+
jQuery.data(elem, "foo", undefined);
|
31
|
+
equal( jQuery.data(elem, "foo"), "baz", "Data is not unset by passing undefined to jQuery.data" );
|
32
|
+
|
33
|
+
jQuery.data(elem, "foo", null);
|
34
|
+
strictEqual( jQuery.data(elem, "foo"), null, "Setting null using jQuery.data works OK" );
|
35
|
+
|
36
|
+
jQuery.data(elem, "foo", "foo1");
|
37
|
+
|
38
|
+
jQuery.data(elem, { "bar" : "baz", "boom" : "bloz" });
|
39
|
+
strictEqual( jQuery.data(elem, "foo"), "foo1", "Passing an object extends the data object instead of replacing it" );
|
40
|
+
equal( jQuery.data(elem, "boom"), "bloz", "Extending the data object works" );
|
41
|
+
|
42
|
+
jQuery._data(elem, "foo", "foo2", true);
|
43
|
+
equal( jQuery._data(elem, "foo"), "foo2", "Setting internal data works" );
|
44
|
+
equal( jQuery.data(elem, "foo"), "foo1", "Setting internal data does not override user data" );
|
45
|
+
|
46
|
+
internalDataObj = jQuery._data( elem );
|
47
|
+
ok( internalDataObj, "Internal data object exists" );
|
48
|
+
notStrictEqual( dataObj, internalDataObj, "Internal data object is not the same as user data object" );
|
49
|
+
|
50
|
+
strictEqual( elem.boom, undefined, "Data is never stored directly on the object" );
|
51
|
+
|
52
|
+
jQuery.removeData(elem, "foo");
|
53
|
+
strictEqual( jQuery.data(elem, "foo"), undefined, "jQuery.removeData removes single properties" );
|
54
|
+
|
55
|
+
jQuery.removeData(elem);
|
56
|
+
strictEqual( jQuery._data(elem), internalDataObj, "jQuery.removeData does not remove internal data if it exists" );
|
57
|
+
|
58
|
+
jQuery.data(elem, "foo", "foo1");
|
59
|
+
jQuery._data(elem, "foo", "foo2");
|
60
|
+
|
61
|
+
equal( jQuery.data(elem, "foo"), "foo1", "(sanity check) Ensure data is set in user data object" );
|
62
|
+
equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );
|
63
|
+
|
64
|
+
strictEqual( jQuery._data(elem, jQuery.expando), undefined, "Removing the last item in internal data destroys the internal data object" );
|
65
|
+
|
66
|
+
jQuery._data(elem, "foo", "foo2");
|
67
|
+
equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );
|
68
|
+
|
69
|
+
jQuery.removeData(elem, "foo");
|
70
|
+
equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" );
|
71
|
+
}
|
72
|
+
|
73
|
+
test("jQuery.data(div)", 25, function() {
|
74
|
+
var div = document.createElement("div");
|
75
|
+
|
76
|
+
dataTests(div);
|
77
|
+
|
78
|
+
// We stored one key in the private data
|
79
|
+
// assert that nothing else was put in there, and that that
|
80
|
+
// one stayed there.
|
81
|
+
QUnit.expectJqData(div, "foo");
|
82
|
+
});
|
83
|
+
|
84
|
+
test("jQuery.data({})", 25, function() {
|
85
|
+
dataTests({});
|
86
|
+
});
|
87
|
+
|
88
|
+
test("jQuery.data(window)", 25, function() {
|
89
|
+
// remove bound handlers from window object to stop potential false positives caused by fix for #5280 in
|
90
|
+
// transports/xhr.js
|
91
|
+
jQuery(window).off("unload");
|
92
|
+
|
93
|
+
dataTests(window);
|
94
|
+
});
|
95
|
+
|
96
|
+
test("jQuery.data(document)", 25, function() {
|
97
|
+
dataTests(document);
|
98
|
+
|
99
|
+
QUnit.expectJqData(document, "foo");
|
100
|
+
});
|
101
|
+
|
102
|
+
test("Expando cleanup", 4, function() {
|
103
|
+
var expected, actual,
|
104
|
+
div = document.createElement("div");
|
105
|
+
|
106
|
+
function assertExpandoAbsent(message) {
|
107
|
+
if (jQuery.support.deleteExpando) {
|
108
|
+
expected = false;
|
109
|
+
actual = jQuery.expando in div;
|
110
|
+
} else {
|
111
|
+
expected = null;
|
112
|
+
actual = div[ jQuery.expando ];
|
113
|
+
}
|
114
|
+
equal( actual, expected, message );
|
115
|
+
}
|
116
|
+
|
117
|
+
assertExpandoAbsent("There is no expando on new elements");
|
118
|
+
|
119
|
+
jQuery.data(div, "foo", 100);
|
120
|
+
jQuery.data(div, "bar", 200);
|
121
|
+
|
122
|
+
ok(jQuery.expando in div, "There is an expando on the element after using $.data()");
|
123
|
+
|
124
|
+
jQuery.removeData(div, "foo");
|
125
|
+
|
126
|
+
ok(jQuery.expando in div, "There is still an expando on the element after removing (some) of the data");
|
127
|
+
|
128
|
+
jQuery.removeData(div, "bar");
|
129
|
+
|
130
|
+
assertExpandoAbsent("Removing the last item in the data store deletes the expando");
|
131
|
+
|
132
|
+
// Clean up unattached element
|
133
|
+
jQuery(div).remove();
|
134
|
+
});
|
135
|
+
|
136
|
+
test("Data is not being set on comment and text nodes", function() {
|
137
|
+
expect(2);
|
138
|
+
|
139
|
+
ok( !jQuery.hasData( jQuery("<!-- comment -->").data("foo", 0) ) );
|
140
|
+
ok( !jQuery.hasData( jQuery("<span>text</span>").contents().data("foo", 0) ) );
|
141
|
+
|
142
|
+
});
|
143
|
+
|
144
|
+
test("jQuery.acceptData", function() {
|
145
|
+
expect(9);
|
146
|
+
|
147
|
+
var flash, applet;
|
148
|
+
|
149
|
+
ok( jQuery.acceptData( document ), "document" );
|
150
|
+
ok( jQuery.acceptData( document.documentElement ), "documentElement" );
|
151
|
+
ok( jQuery.acceptData( {} ), "object" );
|
152
|
+
ok( !jQuery.acceptData( document.createElement("embed") ), "embed" );
|
153
|
+
ok( !jQuery.acceptData( document.createElement("applet") ), "applet" );
|
154
|
+
|
155
|
+
flash = document.createElement("object");
|
156
|
+
flash.setAttribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
|
157
|
+
ok( jQuery.acceptData( flash ), "flash" );
|
158
|
+
|
159
|
+
applet = document.createElement("object");
|
160
|
+
applet.setAttribute("classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93");
|
161
|
+
ok( !jQuery.acceptData( applet ), "applet" );
|
162
|
+
|
163
|
+
ok( !jQuery.acceptData( document.createComment("") ), "comment" );
|
164
|
+
ok( !jQuery.acceptData( document.createTextNode("") ), "text" );
|
165
|
+
});
|
166
|
+
|
167
|
+
test(".data()", function() {
|
168
|
+
expect(5);
|
169
|
+
|
170
|
+
var div, dataObj, nodiv, obj;
|
171
|
+
|
172
|
+
div = jQuery("#foo");
|
173
|
+
strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" );
|
174
|
+
div.data("test", "success");
|
175
|
+
|
176
|
+
dataObj = div.data();
|
177
|
+
|
178
|
+
deepEqual( dataObj, {test: "success"}, "data() returns entire data object with expected properties" );
|
179
|
+
strictEqual( div.data("foo"), undefined, "Make sure that missing result is still undefined" );
|
180
|
+
|
181
|
+
nodiv = jQuery("#unfound");
|
182
|
+
equal( nodiv.data(), null, "data() on empty set returns null" );
|
183
|
+
|
184
|
+
obj = { foo: "bar" };
|
185
|
+
jQuery(obj).data("foo", "baz");
|
186
|
+
|
187
|
+
dataObj = jQuery.extend(true, {}, jQuery(obj).data());
|
188
|
+
|
189
|
+
deepEqual( dataObj, { "foo": "baz" }, "Retrieve data object from a wrapped JS object (#7524)" );
|
190
|
+
});
|
191
|
+
|
192
|
+
function testDataTypes( $obj ) {
|
193
|
+
jQuery.each({
|
194
|
+
"null": null,
|
195
|
+
"true": true,
|
196
|
+
"false": false,
|
197
|
+
"zero": 0,
|
198
|
+
"one": 1,
|
199
|
+
"empty string": "",
|
200
|
+
"empty array": [],
|
201
|
+
"array": [1],
|
202
|
+
"empty object": {},
|
203
|
+
"object": { foo: "bar" },
|
204
|
+
"date": new Date(),
|
205
|
+
"regex": /test/,
|
206
|
+
"function": function() {}
|
207
|
+
}, function( type, value ) {
|
208
|
+
strictEqual( $obj.data( "test", value ).data("test"), value, "Data set to " + type );
|
209
|
+
});
|
210
|
+
}
|
211
|
+
|
212
|
+
test("jQuery(Element).data(String, Object).data(String)", function() {
|
213
|
+
expect( 18 );
|
214
|
+
var parent = jQuery("<div><div></div></div>"),
|
215
|
+
div = parent.children();
|
216
|
+
|
217
|
+
strictEqual( div.data("test"), undefined, "No data exists initially" );
|
218
|
+
strictEqual( div.data("test", "success").data("test"), "success", "Data added" );
|
219
|
+
strictEqual( div.data("test", "overwritten").data("test"), "overwritten", "Data overwritten" );
|
220
|
+
strictEqual( div.data("test", undefined).data("test"), "overwritten", ".data(key,undefined) does nothing but is chainable (#5571)");
|
221
|
+
strictEqual( div.data("notexist"), undefined, "No data exists for unset key" );
|
222
|
+
testDataTypes( div );
|
223
|
+
|
224
|
+
parent.remove();
|
225
|
+
});
|
226
|
+
|
227
|
+
test("jQuery(plain Object).data(String, Object).data(String)", function() {
|
228
|
+
expect( 16 );
|
229
|
+
|
230
|
+
// #3748
|
231
|
+
var $obj = jQuery({ exists: true });
|
232
|
+
strictEqual( $obj.data("nothing"), undefined, "Non-existent data returns undefined");
|
233
|
+
strictEqual( $obj.data("exists"), undefined, "Object properties are not returned as data" );
|
234
|
+
testDataTypes( $obj );
|
235
|
+
|
236
|
+
// Clean up
|
237
|
+
$obj.removeData();
|
238
|
+
deepEqual( $obj[0], { exists: true }, "removeData does not clear the object" );
|
239
|
+
});
|
240
|
+
|
241
|
+
test("data-* attributes", function() {
|
242
|
+
expect(40);
|
243
|
+
var prop, i, l, metadata, elem,
|
244
|
+
obj, obj2, check, num, num2,
|
245
|
+
div = jQuery("<div>"),
|
246
|
+
child = jQuery("<div data-myobj='old data' data-ignored=\"DOM\" data-other='test'></div>"),
|
247
|
+
dummy = jQuery("<div data-myobj='old data' data-ignored=\"DOM\" data-other='test'></div>");
|
248
|
+
|
249
|
+
equal( div.data("attr"), undefined, "Check for non-existing data-attr attribute" );
|
250
|
+
|
251
|
+
div.attr("data-attr", "exists");
|
252
|
+
equal( div.data("attr"), "exists", "Check for existing data-attr attribute" );
|
253
|
+
|
254
|
+
div.attr("data-attr", "exists2");
|
255
|
+
equal( div.data("attr"), "exists", "Check that updates to data- don't update .data()" );
|
256
|
+
|
257
|
+
div.data("attr", "internal").attr("data-attr", "external");
|
258
|
+
equal( div.data("attr"), "internal", "Check for .data('attr') precedence (internal > external data-* attribute)" );
|
259
|
+
|
260
|
+
div.remove();
|
261
|
+
|
262
|
+
child.appendTo("#qunit-fixture");
|
263
|
+
equal( child.data("myobj"), "old data", "Value accessed from data-* attribute");
|
264
|
+
|
265
|
+
child.data("myobj", "replaced");
|
266
|
+
equal( child.data("myobj"), "replaced", "Original data overwritten");
|
267
|
+
|
268
|
+
child.data("ignored", "cache");
|
269
|
+
equal( child.data("ignored"), "cache", "Cached data used before DOM data-* fallback");
|
270
|
+
|
271
|
+
obj = child.data();
|
272
|
+
obj2 = dummy.data();
|
273
|
+
check = [ "myobj", "ignored", "other" ];
|
274
|
+
num = 0;
|
275
|
+
num2 = 0;
|
276
|
+
|
277
|
+
dummy.remove();
|
278
|
+
|
279
|
+
for ( i = 0, l = check.length; i < l; i++ ) {
|
280
|
+
ok( obj[ check[i] ], "Make sure data- property exists when calling data-." );
|
281
|
+
ok( obj2[ check[i] ], "Make sure data- property exists when calling data-." );
|
282
|
+
}
|
283
|
+
|
284
|
+
for ( prop in obj ) {
|
285
|
+
num++;
|
286
|
+
}
|
287
|
+
|
288
|
+
equal( num, check.length, "Make sure that the right number of properties came through." );
|
289
|
+
|
290
|
+
for ( prop in obj2 ) {
|
291
|
+
num2++;
|
292
|
+
}
|
293
|
+
|
294
|
+
equal( num2, check.length, "Make sure that the right number of properties came through." );
|
295
|
+
|
296
|
+
child.attr("data-other", "newvalue");
|
297
|
+
|
298
|
+
equal( child.data("other"), "test", "Make sure value was pulled in properly from a .data()." );
|
299
|
+
|
300
|
+
child
|
301
|
+
.attr("data-true", "true")
|
302
|
+
.attr("data-false", "false")
|
303
|
+
.attr("data-five", "5")
|
304
|
+
.attr("data-point", "5.5")
|
305
|
+
.attr("data-pointe", "5.5E3")
|
306
|
+
.attr("data-grande", "5.574E9")
|
307
|
+
.attr("data-hexadecimal", "0x42")
|
308
|
+
.attr("data-pointbad", "5..5")
|
309
|
+
.attr("data-pointbad2", "-.")
|
310
|
+
.attr("data-bigassnum", "123456789123456789123456789")
|
311
|
+
.attr("data-badjson", "{123}")
|
312
|
+
.attr("data-badjson2", "[abc]")
|
313
|
+
.attr("data-empty", "")
|
314
|
+
.attr("data-space", " ")
|
315
|
+
.attr("data-null", "null")
|
316
|
+
.attr("data-string", "test");
|
317
|
+
|
318
|
+
strictEqual( child.data("true"), true, "Primitive true read from attribute");
|
319
|
+
strictEqual( child.data("false"), false, "Primitive false read from attribute");
|
320
|
+
strictEqual( child.data("five"), 5, "Primitive number read from attribute");
|
321
|
+
strictEqual( child.data("point"), 5.5, "Primitive number read from attribute");
|
322
|
+
strictEqual( child.data("pointe"), "5.5E3", "Floating point exponential number read from attribute");
|
323
|
+
strictEqual( child.data("grande"), "5.574E9", "Big exponential number read from attribute");
|
324
|
+
strictEqual( child.data("hexadecimal"), "0x42", "Hexadecimal number read from attribute");
|
325
|
+
strictEqual( child.data("pointbad"), "5..5", "Bad number read from attribute");
|
326
|
+
strictEqual( child.data("pointbad2"), "-.", "Bad number read from attribute");
|
327
|
+
strictEqual( child.data("bigassnum"), "123456789123456789123456789", "Bad bigass number read from attribute");
|
328
|
+
strictEqual( child.data("badjson"), "{123}", "Bad number read from attribute");
|
329
|
+
strictEqual( child.data("badjson2"), "[abc]", "Bad number read from attribute");
|
330
|
+
strictEqual( child.data("empty"), "", "Empty string read from attribute");
|
331
|
+
strictEqual( child.data("space"), " ", "Empty string read from attribute");
|
332
|
+
strictEqual( child.data("null"), null, "Primitive null read from attribute");
|
333
|
+
strictEqual( child.data("string"), "test", "Typical string read from attribute");
|
334
|
+
|
335
|
+
child.remove();
|
336
|
+
|
337
|
+
// tests from metadata plugin
|
338
|
+
function testData(index, elem) {
|
339
|
+
switch (index) {
|
340
|
+
case 0:
|
341
|
+
equal(jQuery(elem).data("foo"), "bar", "Check foo property");
|
342
|
+
equal(jQuery(elem).data("bar"), "baz", "Check baz property");
|
343
|
+
break;
|
344
|
+
case 1:
|
345
|
+
equal(jQuery(elem).data("test"), "bar", "Check test property");
|
346
|
+
equal(jQuery(elem).data("bar"), "baz", "Check bar property");
|
347
|
+
break;
|
348
|
+
case 2:
|
349
|
+
equal(jQuery(elem).data("zoooo"), "bar", "Check zoooo property");
|
350
|
+
deepEqual(jQuery(elem).data("bar"), {"test":"baz"}, "Check bar property");
|
351
|
+
break;
|
352
|
+
case 3:
|
353
|
+
equal(jQuery(elem).data("number"), true, "Check number property");
|
354
|
+
deepEqual(jQuery(elem).data("stuff"), [2,8], "Check stuff property");
|
355
|
+
break;
|
356
|
+
default:
|
357
|
+
ok(false, ["Assertion failed on index ", index, ", with data"].join(""));
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
metadata = "<ol><li class='test test2' data-foo='bar' data-bar='baz' data-arr='[1,2]'>Some stuff</li><li class='test test2' data-test='bar' data-bar='baz'>Some stuff</li><li class='test test2' data-zoooo='bar' data-bar='{\"test\":\"baz\"}'>Some stuff</li><li class='test test2' data-number=true data-stuff='[2,8]'>Some stuff</li></ol>";
|
362
|
+
elem = jQuery(metadata).appendTo("#qunit-fixture");
|
363
|
+
|
364
|
+
elem.find("li").each(testData);
|
365
|
+
elem.remove();
|
366
|
+
});
|
367
|
+
|
368
|
+
test(".data(Object)", function() {
|
369
|
+
expect(4);
|
370
|
+
|
371
|
+
var obj, jqobj,
|
372
|
+
div = jQuery("<div/>");
|
373
|
+
|
374
|
+
div.data({ "test": "in", "test2": "in2" });
|
375
|
+
equal( div.data("test"), "in", "Verify setting an object in data" );
|
376
|
+
equal( div.data("test2"), "in2", "Verify setting an object in data" );
|
377
|
+
|
378
|
+
obj = {test:"unset"};
|
379
|
+
jqobj = jQuery(obj);
|
380
|
+
|
381
|
+
jqobj.data("test", "unset");
|
382
|
+
jqobj.data({ "test": "in", "test2": "in2" });
|
383
|
+
equal( jQuery.data(obj)["test"], "in", "Verify setting an object on an object extends the data object" );
|
384
|
+
equal( obj["test2"], undefined, "Verify setting an object on an object does not extend the object" );
|
385
|
+
|
386
|
+
// manually clean up detached elements
|
387
|
+
div.remove();
|
388
|
+
});
|
389
|
+
|
390
|
+
test("jQuery.removeData", function() {
|
391
|
+
expect(10);
|
392
|
+
|
393
|
+
var obj,
|
394
|
+
div = jQuery("#foo")[0];
|
395
|
+
jQuery.data(div, "test", "testing");
|
396
|
+
jQuery.removeData(div, "test");
|
397
|
+
equal( jQuery.data(div, "test"), undefined, "Check removal of data" );
|
398
|
+
|
399
|
+
jQuery.data(div, "test2", "testing");
|
400
|
+
jQuery.removeData( div );
|
401
|
+
ok( !jQuery.data(div, "test2"), "Make sure that the data property no longer exists." );
|
402
|
+
ok( !div[ jQuery.expando ], "Make sure the expando no longer exists, as well." );
|
403
|
+
|
404
|
+
jQuery.data(div, {
|
405
|
+
test3: "testing",
|
406
|
+
test4: "testing"
|
407
|
+
});
|
408
|
+
jQuery.removeData( div, "test3 test4" );
|
409
|
+
ok( !jQuery.data(div, "test3") || jQuery.data(div, "test4"), "Multiple delete with spaces." );
|
410
|
+
|
411
|
+
jQuery.data(div, {
|
412
|
+
test3: "testing",
|
413
|
+
test4: "testing"
|
414
|
+
});
|
415
|
+
jQuery.removeData( div, [ "test3", "test4" ] );
|
416
|
+
ok( !jQuery.data(div, "test3") || jQuery.data(div, "test4"), "Multiple delete by array." );
|
417
|
+
|
418
|
+
jQuery.data(div, {
|
419
|
+
"test3 test4": "testing",
|
420
|
+
"test3": "testing"
|
421
|
+
});
|
422
|
+
jQuery.removeData( div, "test3 test4" );
|
423
|
+
ok( !jQuery.data(div, "test3 test4"), "Multiple delete with spaces deleted key with exact name" );
|
424
|
+
ok( jQuery.data(div, "test3"), "Left the partial matched key alone" );
|
425
|
+
|
426
|
+
obj = {};
|
427
|
+
jQuery.data(obj, "test", "testing");
|
428
|
+
equal( jQuery(obj).data("test"), "testing", "verify data on plain object");
|
429
|
+
jQuery.removeData(obj, "test");
|
430
|
+
equal( jQuery.data(obj, "test"), undefined, "Check removal of data on plain object" );
|
431
|
+
|
432
|
+
jQuery.data( window, "BAD", true );
|
433
|
+
jQuery.removeData( window, "BAD" );
|
434
|
+
ok( !jQuery.data( window, "BAD" ), "Make sure that the value was not still set." );
|
435
|
+
});
|
436
|
+
|
437
|
+
test(".removeData()", function() {
|
438
|
+
expect(6);
|
439
|
+
var div = jQuery("#foo");
|
440
|
+
div.data("test", "testing");
|
441
|
+
div.removeData("test");
|
442
|
+
equal( div.data("test"), undefined, "Check removal of data" );
|
443
|
+
|
444
|
+
div.data("test", "testing");
|
445
|
+
div.data("test.foo", "testing2");
|
446
|
+
div.removeData("test.bar");
|
447
|
+
equal( div.data("test.foo"), "testing2", "Make sure data is intact" );
|
448
|
+
equal( div.data("test"), "testing", "Make sure data is intact" );
|
449
|
+
|
450
|
+
div.removeData("test");
|
451
|
+
equal( div.data("test.foo"), "testing2", "Make sure data is intact" );
|
452
|
+
equal( div.data("test"), undefined, "Make sure data is intact" );
|
453
|
+
|
454
|
+
div.removeData("test.foo");
|
455
|
+
equal( div.data("test.foo"), undefined, "Make sure data is intact" );
|
456
|
+
});
|
457
|
+
|
458
|
+
if (window.JSON && window.JSON.stringify) {
|
459
|
+
test("JSON serialization (#8108)", function () {
|
460
|
+
expect(1);
|
461
|
+
|
462
|
+
var obj = { "foo": "bar" };
|
463
|
+
jQuery.data(obj, "hidden", true);
|
464
|
+
|
465
|
+
equal( JSON.stringify(obj), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
|
466
|
+
});
|
467
|
+
}
|
468
|
+
|
469
|
+
test("jQuery.data should follow html5 specification regarding camel casing", function() {
|
470
|
+
expect(10);
|
471
|
+
|
472
|
+
var div = jQuery("<div id='myObject' data-w-t-f='ftw' data-big-a-little-a='bouncing-b' data-foo='a' data-foo-bar='b' data-foo-bar-baz='c'></div>")
|
473
|
+
.prependTo("body");
|
474
|
+
|
475
|
+
equal( div.data()["wTF"], "ftw", "Verify single letter data-* key" );
|
476
|
+
equal( div.data()["bigALittleA"], "bouncing-b", "Verify single letter mixed data-* key" );
|
477
|
+
|
478
|
+
equal( div.data()["foo"], "a", "Verify single word data-* key" );
|
479
|
+
equal( div.data()["fooBar"], "b", "Verify multiple word data-* key" );
|
480
|
+
equal( div.data()["fooBarBaz"], "c", "Verify multiple word data-* key" );
|
481
|
+
|
482
|
+
equal( div.data("foo"), "a", "Verify single word data-* key" );
|
483
|
+
equal( div.data("fooBar"), "b", "Verify multiple word data-* key" );
|
484
|
+
equal( div.data("fooBarBaz"), "c", "Verify multiple word data-* key" );
|
485
|
+
|
486
|
+
div.data("foo-bar", "d");
|
487
|
+
|
488
|
+
equal( div.data("fooBar"), "d", "Verify updated data-* key" );
|
489
|
+
equal( div.data("foo-bar"), "d", "Verify updated data-* key" );
|
490
|
+
|
491
|
+
div.remove();
|
492
|
+
});
|
493
|
+
|
494
|
+
test("jQuery.data should not miss data with preset hyphenated property names", function() {
|
495
|
+
|
496
|
+
expect(2);
|
497
|
+
|
498
|
+
var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
|
499
|
+
test = {
|
500
|
+
"camelBar": "camelBar",
|
501
|
+
"hyphen-foo": "hyphen-foo"
|
502
|
+
};
|
503
|
+
|
504
|
+
div.data( test );
|
505
|
+
|
506
|
+
jQuery.each( test , function(i, k) {
|
507
|
+
equal( div.data(k), k, "data with property '"+k+"' was correctly found");
|
508
|
+
});
|
509
|
+
});
|
510
|
+
|
511
|
+
test("jQuery.data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() {
|
512
|
+
|
513
|
+
var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
|
514
|
+
datas = {
|
515
|
+
"non-empty": "a string",
|
516
|
+
"empty-string": "",
|
517
|
+
"one-value": 1,
|
518
|
+
"zero-value": 0,
|
519
|
+
"an-array": [],
|
520
|
+
"an-object": {},
|
521
|
+
"bool-true": true,
|
522
|
+
"bool-false": false,
|
523
|
+
// JSHint enforces double quotes,
|
524
|
+
// but JSON strings need double quotes to parse
|
525
|
+
// so we need escaped double quotes here
|
526
|
+
"some-json": "{ \"foo\": \"bar\" }",
|
527
|
+
"num-1-middle": true,
|
528
|
+
"num-end-2": true,
|
529
|
+
"2-num-start": true
|
530
|
+
};
|
531
|
+
|
532
|
+
expect( 24 );
|
533
|
+
|
534
|
+
jQuery.each( datas, function( key, val ) {
|
535
|
+
div.data( key, val );
|
536
|
+
|
537
|
+
deepEqual( div.data( key ), val, "get: " + key );
|
538
|
+
deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
|
539
|
+
});
|
540
|
+
});
|
541
|
+
|
542
|
+
test("jQuery.data supports interoperable removal of hyphenated/camelCase properties", function() {
|
543
|
+
var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
|
544
|
+
datas = {
|
545
|
+
"non-empty": "a string",
|
546
|
+
"empty-string": "",
|
547
|
+
"one-value": 1,
|
548
|
+
"zero-value": 0,
|
549
|
+
"an-array": [],
|
550
|
+
"an-object": {},
|
551
|
+
"bool-true": true,
|
552
|
+
"bool-false": false,
|
553
|
+
// JSHint enforces double quotes,
|
554
|
+
// but JSON strings need double quotes to parse
|
555
|
+
// so we need escaped double quotes here
|
556
|
+
"some-json": "{ \"foo\": \"bar\" }"
|
557
|
+
};
|
558
|
+
|
559
|
+
expect( 27 );
|
560
|
+
|
561
|
+
jQuery.each( datas, function( key, val ) {
|
562
|
+
div.data( key, val );
|
563
|
+
|
564
|
+
deepEqual( div.data( key ), val, "get: " + key );
|
565
|
+
deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
|
566
|
+
|
567
|
+
div.removeData( key );
|
568
|
+
|
569
|
+
equal( div.data( key ), undefined, "get: " + key );
|
570
|
+
|
571
|
+
});
|
572
|
+
});
|
573
|
+
|
574
|
+
test( ".removeData supports removal of hyphenated properties via array (#12786)", function() {
|
575
|
+
expect( 4 );
|
576
|
+
|
577
|
+
var div, plain, compare;
|
578
|
+
|
579
|
+
div = jQuery("<div>").appendTo("#qunit-fixture");
|
580
|
+
plain = jQuery({});
|
581
|
+
|
582
|
+
// When data is batch assigned (via plain object), the properties
|
583
|
+
// are not camel cased as they are with (property, value) calls
|
584
|
+
compare = {
|
585
|
+
// From batch assignment .data({ "a-a": 1 })
|
586
|
+
"a-a": 1,
|
587
|
+
// From property, value assignment .data( "b-b", 1 )
|
588
|
+
"bB": 1
|
589
|
+
};
|
590
|
+
|
591
|
+
// Mixed assignment
|
592
|
+
div.data({ "a-a": 1 }).data( "b-b", 1 );
|
593
|
+
plain.data({ "a-a": 1 }).data( "b-b", 1 );
|
594
|
+
|
595
|
+
deepEqual( div.data(), compare, "Data appears as expected. (div)" );
|
596
|
+
deepEqual( plain.data(), compare, "Data appears as expected. (plain)" );
|
597
|
+
|
598
|
+
div.removeData([ "a-a", "b-b" ]);
|
599
|
+
plain.removeData([ "a-a", "b-b" ]);
|
600
|
+
|
601
|
+
// NOTE: Timo's proposal for "propEqual" (or similar) would be nice here
|
602
|
+
deepEqual( div.data(), {}, "Data is empty. (div)" );
|
603
|
+
deepEqual( plain.data(), {}, "Data is empty. (plain)" );
|
604
|
+
});
|
605
|
+
|
606
|
+
// Test originally by Moschel
|
607
|
+
test("Triggering the removeData should not throw exceptions. (#10080)", function() {
|
608
|
+
expect(1);
|
609
|
+
stop();
|
610
|
+
var frame = jQuery("#loadediframe");
|
611
|
+
jQuery(frame[0].contentWindow).on("unload", function() {
|
612
|
+
ok(true, "called unload");
|
613
|
+
start();
|
614
|
+
});
|
615
|
+
// change the url to trigger unload
|
616
|
+
frame.attr("src", "data/iframe.html?param=true");
|
617
|
+
});
|
618
|
+
|
619
|
+
test( "Only check element attributes once when calling .data() - #8909", function() {
|
620
|
+
expect( 2 );
|
621
|
+
var testing = {
|
622
|
+
"test": "testing",
|
623
|
+
"test2": "testing"
|
624
|
+
},
|
625
|
+
element = jQuery( "<div data-test='testing'>" ),
|
626
|
+
node = element[ 0 ];
|
627
|
+
|
628
|
+
// set an attribute using attr to ensure it
|
629
|
+
node.setAttribute( "data-test2", "testing" );
|
630
|
+
deepEqual( element.data(), testing, "Sanity Check" );
|
631
|
+
|
632
|
+
node.setAttribute( "data-test3", "testing" );
|
633
|
+
deepEqual( element.data(), testing, "The data didn't change even though the data-* attrs did" );
|
634
|
+
|
635
|
+
// clean up data cache
|
636
|
+
element.remove();
|
637
|
+
});
|
638
|
+
|
639
|
+
test( "JSON data- attributes can have newlines", function() {
|
640
|
+
expect(1);
|
641
|
+
|
642
|
+
var x = jQuery("<div data-some='{\n\"foo\":\n\t\"bar\"\n}'></div>");
|
643
|
+
equal( x.data("some").foo, "bar", "got a JSON data- attribute with spaces" );
|
644
|
+
x.remove();
|
645
|
+
});
|