Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce88188

Browse files
committed
feat(jQuery): どういう用途に向いてる/向いていない を追加
1 parent13f26de commitce88188

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎ja/jQuery/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,26 @@ jQuery.fn = jQuery.prototype = {
3535
$(document.body); // 返り値はjQueryのインスタンス
3636
```
3737

38-
3938
つまり、jQueryプラグインはJavaScriptのprototypeをそのまま利用しているだけに過ぎないということがわかります。
4039

40+
##どういう用途に向いている?
41+
42+
jQueryプラグインの仕組みがわかったのでどういう用途に有効な仕組みなのか考えてみましょう。
43+
44+
単純なprototype拡張であると言えるので、利点はJavaScriptのprototypeと同様と言えるかもしれません。
45+
動的にメソッドを追加するだけではなく、既存の実装を上書きするmonkey patchのようなものもプラグインとして追加することができます。
46+
47+
##どういう用途に向いていない?
48+
49+
これもJavaScriptのprototypeと同様で、prototypeによる拡張は柔軟すぎるため、
50+
jQuery自体がプラグインのコントロールをすることが難しいです。
51+
52+
また、プラグインが拡張するjQueryの実装に依存し易いため、
53+
jQueryのバージョンによって動かなくなるプラグインが発生しやすいです。
54+
55+
jQueryではそこをどうやってカバーしているかというと、
56+
ドキュメント化されてないAPIは触っていけないというルールを設けているだけとなっています。
57+
4158
##実装してみよう
4259

4360
`calculator`という拡張可能な計算機をjQuery Pluginと同じ方法で作ってみたいと思います。

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp