無標(biāo)題文章

#[jQuery](https://jquery.com/)— New Wave JavaScript

ajax/script: TheAJAX transport only; used to retrieve scripts.

ajax/jsonp: The JSONP AJAX transport only; depends on the ajax/script transport.

css: The.css()method. Also removesallmodules depending on css (includingeffects,dimensions, andoffset).

css/showHide: Non-animated.show(),.hide()and.toggle(); can be excluded if you use classes or explicit.css()calls to set thedisplayproperty. Also removes theeffectsmodule.

deprecated: Methods documented as deprecated but not yet removed.

dimensions: The.width()and.height()methods, includinginner-andouter-variations.

effects: The.animate()method and its shorthands such as.slideUp()or.hide("slow").

event: The.on()and.off()methods and all event functionality. Also removesevent/alias.

event/alias: All event attaching/triggering shorthands like.click()or.mouseover().

event/focusin: Cross-browser support for the focusin and focusout events.

event/trigger: The.trigger()and.triggerHandler()methods. Used byaliasandfocusinmodules.

offset: The.offset(),.position(),.offsetParent(),.scrollLeft(), and.scrollTop()methods.

wrap: The.wrap(),.wrapAll(),.wrapInner(), and.unwrap()methods.

core/ready: Exclude the ready module if you place your scripts at the end of the body. Any ready callbacks bound withjQuery()will simply be called immediately. However,jQuery(document).ready()will not be a function and.on("ready", ...)or similar will not be triggered.

deferred: Exclude jQuery.Deferred. This also removes jQuery.Callbacks.Notethat modules that depend on jQuery.Deferred(AJAX, effects, core/ready) will not be removed and will still expect jQuery.Deferred to be there. Include your own jQuery.Deferred implementation or exclude those modules as well (grunt custom:-deferred,-ajax,-effects,-core/ready).

exports/global: Exclude the attachment of global jQuery variables ($ and jQuery) to the window.

exports/amd: Exclude the AMD definition.

As a special case, you may also replace Sizzle by using a special flaggrunt custom:-sizzle.

sizzle: The Sizzle selector engine. When this module is excluded, it is replaced by a rudimentary selector engine based on the browser'squerySelectorAllmethod that does not support jQuery selector extensions or enhanced semantics. See theselector-native.jsfile for details.

Note: Excluding Sizzle will also exclude all jQuery selector extensions (such aseffects/animatedSelectorandcss/hiddenVisibleSelectors).

The build process shows a message for each dependent module it excludes or includes.

AMD name

As an option, you can set the module name for jQuery's AMD definition. By default, it is set to "jquery", which plays nicely with plugins and third-party libraries, but there may be cases where you'd like to change this. Simply set the"amd"option:

grunt custom --amd="custom-name"

Or, to define anonymously, set the name to an empty string.

grunt custom --amd=""

Custom Build Examples

To create a custom build, first check out the version:

git pull;git checkout VERSION

Where VERSION is the version you want to customize. Then, make sure all Node dependencies are installed:

npm install

Create the custom build using thegrunt customoption, listing the modules to be excluded.

Exclude allajaxfunctionality:

grunt custom:-ajax

Excludingcssremoves modules depending on CSS:effects,offset,dimensions.

grunt custom:-css

Exclude a bunch of modules:

grunt custom:-ajax,-css,-deprecated,-dimensions,-effects,-event/alias,-offset,-wrap

For questions or requests regarding custom builds, please start a thread on theDeveloping jQuery Coresection of the forum. Due to the combinatorics and custom nature of these builds, they are not regularly tested in jQuery's unit test process. The non-Sizzle selector engine currently does not pass unit tests because it is missing too much essential functionality.

Running the Unit Tests

Make sure you have the necessary dependencies:

npm install

Startgrunt watchornpm startto auto-build jQuery as you work:

grunt watch

Run the unit tests with a local server that supports PHP. Ensure that you run the site from the root directory, not the "test" directory. No database is required. Pre-configured php local servers are available for Windows and Mac. Here are some options:

Windows:WAMP download

Mac:MAMP download

Linux:Setting up LAMP

Mongoose (most platforms)

Building to a different directory

To copy the built jQuery files from/distto another directory:

grunt&&grunt dist:/path/to/special/location/

With this example, the output files would be:

/path/to/special/location/jquery.js

/path/to/special/location/jquery.min.js

To add a permanent copy destination, create a file indist/called ".destination.json". Inside the file, paste and customize the following:

{"/Absolute/path/to/other/destination":true}

Additionally, both methods can be combined.

Essential Git

As the source code is handled by the Git version control system, it's useful to know some features used.

Cleaning

If you want to purge your working directory back to the status of upstream, the following commands can be used (remember everything you've worked on is gone after these):

git reset --hard upstream/master

git clean -fdx

Rebasing

For feature/topic branches, you should always use the--rebaseflag togit pull, or if you are usually handling many temporary "to be in a github pull request" branches, run the following to automate this:

git config branch.autosetuprebaselocal

(seeman git-configfor more information)

Handling merge conflicts

If you're getting merge conflicts when merging, instead of editing the conflicted files manually, you can use the featuregit mergetool. Even though the default toolxxdifflooks awful/old, it's rather useful.

The following are some commands that can be used there:

Ctrl + Alt + M- automerge as much as possible

b- jump to next merge conflict

s- change the order of the conflicted lines

u- undo a merge

left mouse button- mark a block to be the winner

middle mouse button- mark a line to be the winner

Ctrl + S- save

Ctrl + Q- quit

QUnitReference

Test methods

expect( numAssertions );stop();start();

Note: QUnit's eventual addition of an argument to stop/start is ignored in this test suite so that start and stop can be passed as callbacks without worrying about their parameters.

Test assertions

ok( value, [message] );equal( actual, expected, [message] );notEqual( actual, expected, [message] );deepEqual( actual, expected, [message] );notDeepEqual( actual, expected, [message] );strictEqual( actual, expected, [message] );notStrictEqual( actual, expected, [message] );throws( block, [expected], [message] );

Test Suite Convenience Methods Reference (Seetest/data/testinit.js)

Returns an array of elements with the given IDs

q(...);

Example:

q("main","foo","bar");=>[ div#main, span#foo, input#bar ]

Asserts that a selection matches the given IDs

t( testName, selector, ["array","of","ids"] );

Example:

t("Check for something","http://[a]", ["foo","bar"]);

Fires a native DOM event without going through jQuery

fireNative( node, eventType )

Example:

fireNative(jQuery("#elem")[0],"click");

Add random number to url to stop caching

url("some/url.php");

Example:

url("data/test.html");=>"data/test.html?10538358428943"url("data/test.php?foo=bar");=>"data/test.php?foo=bar&10538358345554"

Run tests in an iframe

Some tests may require a document other than the standard test fixture, and these can be run in a separate iframe. The actual test code and assertions remain in jQuery's main test files; only the minimal test fixture markup and setup code should be placed in the iframe file.

testIframe( testName, fileName,functiontestCallback(assert,jQuery,window,document,? [additionalargs] ) {...} );

This loads a page, constructing a url with fileName"./data/" + fileName. The iframed page determines when the callback occurs in the test by including the "/test/data/iframeTest.js" script and callingstartIframeTest( [ additional args ] )when appropriate. Often this will be after either document ready orwindow.onloadfires.

ThetestCallbackreceives the QUnitassertobject created bytestIframefor this test, followed by the globaljQuery,window, anddocumentfrom the iframe. If the iframe code passes any arguments tostartIframeTest, they follow thedocumentargument.

Questions?

If you have any questions, please feel free to ask on theDeveloping jQuery Core forumor in #jquery on irc.freenode.net.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子租漂,更是在濱河造成了極大的恐慌磺陡,老刑警劉巖,帶你破解...
    沈念sama閱讀 210,835評論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件友存,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)核畴,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 89,900評論 2 383
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來冲九,“玉大人谤草,你說我怎么就攤上這事。” “怎么了丑孩?”我有些...
    開封第一講書人閱讀 156,481評論 0 345
  • 文/不壞的土叔 我叫張陵泳炉,是天一觀的道長。 經(jīng)常有香客問我嚎杨,道長花鹅,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,303評論 1 282
  • 正文 為了忘掉前任枫浙,我火速辦了婚禮刨肃,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘箩帚。我一直安慰自己真友,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,375評論 5 384
  • 文/花漫 我一把揭開白布紧帕。 她就那樣靜靜地躺著盔然,像睡著了一般。 火紅的嫁衣襯著肌膚如雪是嗜。 梳的紋絲不亂的頭發(fā)上愈案,一...
    開封第一講書人閱讀 49,729評論 1 289
  • 那天,我揣著相機(jī)與錄音鹅搪,去河邊找鬼站绪。 笑死,一個胖子當(dāng)著我的面吹牛丽柿,可吹牛的內(nèi)容都是我干的恢准。 我是一名探鬼主播,決...
    沈念sama閱讀 38,877評論 3 404
  • 文/蒼蘭香墨 我猛地睜開眼甫题,長吁一口氣:“原來是場噩夢啊……” “哼馁筐!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起坠非,我...
    開封第一講書人閱讀 37,633評論 0 266
  • 序言:老撾萬榮一對情侶失蹤敏沉,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后麻顶,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體赦抖,經(jīng)...
    沈念sama閱讀 44,088評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,443評論 2 326
  • 正文 我和宋清朗相戀三年辅肾,在試婚紗的時候發(fā)現(xiàn)自己被綠了队萤。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,563評論 1 339
  • 序言:一個原本活蹦亂跳的男人離奇死亡矫钓,死狀恐怖要尔,靈堂內(nèi)的尸體忽然破棺而出舍杜,到底是詐尸還是另有隱情,我是刑警寧澤赵辕,帶...
    沈念sama閱讀 34,251評論 4 328
  • 正文 年R本政府宣布既绩,位于F島的核電站,受9級特大地震影響还惠,放射性物質(zhì)發(fā)生泄漏饲握。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,827評論 3 312
  • 文/蒙蒙 一蚕键、第九天 我趴在偏房一處隱蔽的房頂上張望救欧。 院中可真熱鬧,春花似錦锣光、人聲如沸笆怠。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,712評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽蹬刷。三九已至,卻和暖如春频丘,著一層夾襖步出監(jiān)牢的瞬間办成,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,943評論 1 264
  • 我被黑心中介騙來泰國打工椎镣, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留诈火,地道東北人兽赁。 一個月前我還...
    沈念sama閱讀 46,240評論 2 360
  • 正文 我出身青樓状答,卻偏偏與公主長得像,于是被迫代替她去往敵國和親刀崖。 傳聞我的和親對象是個殘疾皇子惊科,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,435評論 2 348

推薦閱讀更多精彩內(nèi)容