From b6f2cfa0d8ccbdd1c5490f3c6c80a8592709b5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Mon, 2 Sep 2019 22:40:32 +0200 Subject: [PATCH] All: Upgrade jQuery used in examples from 1.10.2 to 3.4.1, remove deprecated examples The upgrade is necessary to be able to write examples for newer APIs. Examples for removed APIs have been removed as they'd no longer work. Fixes gh-982 --- entries/andSelf.xml | 68 ++------------------------------- entries/context.xml | 7 ++-- entries/deferred.isRejected.xml | 4 +- entries/deferred.isResolved.xml | 4 +- entries/die.xml | 3 ++ entries/error.xml | 5 ++- entries/jQuery.boxModel.xml | 8 +++- entries/jQuery.browser.xml | 6 +++ entries/jQuery.sub.xml | 6 +-- entries/live.xml | 4 +- entries/load-event.xml | 3 ++ entries/selector.xml | 4 +- entries/size.xml | 26 ++----------- entries/unload.xml | 3 ++ entries2html.xsl | 2 +- 15 files changed, 50 insertions(+), 103 deletions(-) diff --git a/entries/andSelf.xml b/entries/andSelf.xml index 5adfd1ae..967c72ef 100644 --- a/entries/andSelf.xml +++ b/entries/andSelf.xml @@ -6,72 +6,10 @@ Add the previous set of elements on the stack to the current set. -

Note: This function has been deprecated and is now an alias for .addBack(), which should be used with jQuery 1.8 and later.

-

As described in the discussion for .end(), jQuery objects maintain an internal stack that keeps track of changes to the matched set of elements. When one of the DOM traversal methods is called, the new set of elements is pushed onto the stack. If the previous set of elements is desired as well, .andSelf() can help.

-

Consider a page with a simple list on it:

-

-<ul>
-  <li>list item 1</li>
-  <li>list item 2</li>
-  <li class="third-item">list item 3</li>
-  <li>list item 4</li>
-  <li>list item 5</li>
-</ul>
-    
-

The result of the following code is a red background behind items 3, 4 and 5:

-

-$( "li.third-item" ).nextAll().andSelf()
-  .css( "background-color", "red" );
-    
-

First, the initial selector locates item 3, initializing the stack with the set containing just this item. The call to .nextAll() then pushes the set of items 4 and 5 onto the stack. Finally, the .andSelf() invocation merges these two sets together, creating a jQuery object that points to all three items in document order: [ <li.third-item>, <li>, <li> ].

+
+

Note: This API has been removed in jQuery 3.0; use .addBack() instead, which should work identically.

+
- - The .andSelf() method causes the previous set of DOM elements in the traversal stack to be added to the current set. In the first example, the top stack contains the set resulting from .find("p"). In the second example, .andSelf() adds the previous set of elements on the stack — in this case $( "div.after-andself" ) — to the current set, selecting both the div and its enclosed paragraphs. - - - - diff --git a/entries/context.xml b/entries/context.xml index 5fc5362a..496c833a 100644 --- a/entries/context.xml +++ b/entries/context.xml @@ -6,7 +6,9 @@ The DOM node context originally passed to jQuery(); if none was passed then context will likely be the document. -

The .context property was deprecated in jQuery 1.10 and is only maintained to the extent needed for supporting .live() in the jQuery Migrate plugin. It may be removed without notice in a future version.

+
+

Note: This API has been removed in jQuery 3.0.

+

The .live() method for binding event handlers uses this property to determine the root element to use for its event delegation needs.

The value of this property is typically equal to document, as this is the default context for jQuery objects if none is supplied. The context may differ if, for example, the object was created by searching within an <iframe> or XML document.

Note that the context property may only apply to the elements originally selected by jQuery(), as it is possible for the user to add elements to the collection via methods such as .add() and these may have a different context.

@@ -18,9 +20,6 @@ $( "ul" ) .append( "
  • " + $( "ul" ).context + "
  • " ) .append( "
  • " + $( "ul", document.body ).context.nodeName + "
  • " ); ]]> - diff --git a/entries/deferred.isRejected.xml b/entries/deferred.isRejected.xml index 5fdd1e95..60ddb77b 100644 --- a/entries/deferred.isRejected.xml +++ b/entries/deferred.isRejected.xml @@ -6,7 +6,9 @@ Determine whether a Deferred object has been rejected. -

    As of jQuery 1.7 this API has been deprecated; please use deferred.state() instead.

    +
    +

    Note: This API has been removed in jQuery 1.8; please use deferred.state() instead.

    +

    Returns true if the Deferred object is in the rejected state, meaning that either deferred.reject() or deferred.rejectWith() has been called for the object and the failCallbacks have been called (or are in the process of being called).

    Note that a Deferred object can be in one of three states: pending, resolved, or rejected; use deferred.isResolved() to determine whether the Deferred object is in the resolved state. These methods are primarily useful for debugging, for example to determine whether a Deferred has already been resolved even though you are inside code that intended to reject it.

    diff --git a/entries/deferred.isResolved.xml b/entries/deferred.isResolved.xml index b5941322..9c046e5a 100644 --- a/entries/deferred.isResolved.xml +++ b/entries/deferred.isResolved.xml @@ -6,7 +6,9 @@ Determine whether a Deferred object has been resolved. -

    This API is deprecated as of jQuery 1.7 and removed as of jQuery 1.8; please use deferred.state() instead.

    +
    +

    Note: This API has been removed in jQuery 1.8; please use deferred.state() instead.

    +

    Returns true if the Deferred object is in the resolved state, meaning that either deferred.resolve() or deferred.resolveWith() has been called for the object and the doneCallbacks have been called (or are in the process of being called).

    Note that a Deferred object can be in one of three states: pending, resolved, or rejected; use deferred.isRejected() to determine whether the Deferred object is in the rejected state. These methods are primarily useful for debugging, for example to determine whether a Deferred has already been resolved even though you are inside code that intended to reject it.

    diff --git a/entries/die.xml b/entries/die.xml index a3d038ec..efe2e614 100644 --- a/entries/die.xml +++ b/entries/die.xml @@ -21,6 +21,9 @@ +
    +

    Note: This API has been removed in jQuery 1.9; please use on() instead.

    +

    Any handler that has been attached with .live() can be removed with .die(). This method is analogous to calling .off() with no arguments, which is used to remove all handlers attached with .on(). See the discussions of .live() and .off() for further details.

    If used without an argument, .die() removes all event handlers previously attached using .live() from the elements.

    diff --git a/entries/error.xml b/entries/error.xml index 6f646aa2..47d9e0e9 100644 --- a/entries/error.xml +++ b/entries/error.xml @@ -20,8 +20,9 @@ -

    This method is a shortcut for .on( "error", handler ).

    -

    As of jQuery 1.8, the .error() method is deprecated. Use .on( "error", handler ) to attach event handlers to the error event instead.

    +
    +

    Note: This API has been removed in jQuery 3.0; please use .on( "error", handler ) instead of .error( handler ) and .trigger( "error" ) instead of .error().

    +

    The error event is sent to elements, such as images, that are referenced by a document and loaded by the browser. It is called if the element was not loaded correctly.

    For example, consider a page with a simple image element:

    
    diff --git a/entries/jQuery.boxModel.xml b/entries/jQuery.boxModel.xml
    index ac464850..b80abe29 100644
    --- a/entries/jQuery.boxModel.xml
    +++ b/entries/jQuery.boxModel.xml
    @@ -4,8 +4,12 @@
       
         1.0
       
    -  States if the current page, in the user's browser, is being rendered using the W3C CSS Box Model. This property was removed in jQuery 1.8. Please try to use feature detection instead.
    -  
    +  States if the current page, in the user's browser, is being rendered using the W3C CSS Box Model.
    +  
    +    
    +

    Note: This API has been removed in jQuery 3.0; check if .document.compatMode is equal to "CSS1Compat" instead. Or, even better - always specify a DOCTYPE and avoid using quirks mode which jQuery doesn't support.

    +
    +
    diff --git a/entries/jQuery.browser.xml b/entries/jQuery.browser.xml index 667ed5f1..11686eae 100644 --- a/entries/jQuery.browser.xml +++ b/entries/jQuery.browser.xml @@ -7,6 +7,9 @@ Contains flags for the useragent, read from navigator.userAgent. This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead. +
    +

    Note: This API has been removed in jQuery 1.9; please rely on feature detection instead.

    +

    The $.browser property provides information about the web browser that is accessing the page, as reported by the browser itself. It contains flags for each of the four most prevalent browser classes (Internet Explorer, Mozilla, Webkit, and Opera) as well as version information.

    Available flags are:

      @@ -56,6 +59,9 @@ $.browser.msie; The version number of the rendering engine for the user's browser. This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. +
      +

      Note: This API has been removed in jQuery 1.9; please rely on feature detection instead.

      +

      Here are some typical results:

      • Internet Explorer: 6.0, 7.0, 8.0
      • diff --git a/entries/jQuery.sub.xml b/entries/jQuery.sub.xml index a52c9ab6..bc0330e4 100644 --- a/entries/jQuery.sub.xml +++ b/entries/jQuery.sub.xml @@ -6,9 +6,9 @@ Creates a new copy of jQuery whose properties and methods can be modified without affecting the original jQuery object. -

        - This method is deprecated as of jQuery 1.7 and will be moved to a plugin in jQuery 1.8. -

        +
        +

        Note: This API has been removed in jQuery 1.9.

        +

        There are two specific use cases for which jQuery.sub() was created. The first was for providing a painless way of overriding jQuery methods without completely destroying the original methods and another was for helping to do encapsulation and basic namespacing for jQuery plugins.

        Note that jQuery.sub() doesn't attempt to do any sort of isolation - that's not its intention. All the methods on the sub'd version of jQuery will still point to the original jQuery (events bound and triggered will still be through the main jQuery, data will be bound to elements through the main jQuery, Ajax queries and events will run through the main jQuery, etc.).

        Note that if you're looking to use this for plugin development you should first strongly consider using something like the jQuery UI widget factory which manages both state and plugin sub-methods. Some examples of using the jQuery UI widget factory to build a plugin.

        diff --git a/entries/live.xml b/entries/live.xml index 049322e2..e88a67ce 100644 --- a/entries/live.xml +++ b/entries/live.xml @@ -32,7 +32,9 @@ -

        As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

        +
        +

        Note: This API has been removed in jQuery 1.9; please use on() instead.

        +

        This method provides a means to attach delegated event handlers to the document element of a page, which simplifies the use of event handlers when content is dynamically added to a page. See the discussion of direct versus delegated events in the .on() method for more information.

        Rewriting the .live() method in terms of its successors is straightforward; these are templates for equivalent calls for all three event attachment methods:

        
        diff --git a/entries/load-event.xml b/entries/load-event.xml
        index e3739cb7..b9669cc6 100644
        --- a/entries/load-event.xml
        +++ b/entries/load-event.xml
        @@ -20,6 +20,9 @@
             
           
           
        +    
        +

        Note: This API has been removed in jQuery 3.0; please use .on( "load", handler ) instead of .load( handler ) and .trigger( "load" ) instead of .load().

        +

        This method is a shortcut for .on( "load", handler ).

        The load event is sent to an element when it and all sub-elements have been completely loaded. This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object.

        For example, consider a page with a simple image:

        diff --git a/entries/selector.xml b/entries/selector.xml index d64fc0aa..229e674b 100644 --- a/entries/selector.xml +++ b/entries/selector.xml @@ -6,7 +6,9 @@ A selector representing selector passed to jQuery(), if any, when creating the original set. -

        The .selector property was deprecated in jQuery 1.7 and is only maintained to the extent needed for supporting .live() in the jQuery Migrate plugin. It may be removed without notice in a future version. The property was never a reliable indicator of the selector that could be used to obtain the set of elements currently contained in the jQuery set where it was a property, since subsequent traversal methods may have changed the set. Plugins that need to use a selector string within their plugin can require it as a parameter of the method. For example, a "foo" plugin could be written as $.fn.foo = function( selector, options ) { /* plugin code goes here */ };, and the person using the plugin would write $( "div.bar" ).foo( "div.bar", {dog: "bark"} ); with the "div.bar" selector repeated as the first argument of .foo().

        +
        +

        Note: This API has been removed in jQuery 3.0. The property was never a reliable indicator of the selector that could be used to obtain the set of elements currently contained in the jQuery set where it was a property, since subsequent traversal methods may have changed the set. Plugins that need to use a selector string within their plugin can require it as a parameter of the method. For example, a "foo" plugin could be written as $.fn.foo = function( selector, options ) { /* plugin code goes here */ };, and the person using the plugin would write $( "div.bar" ).foo( "div.bar", {dog: "bark"} ); with the "div.bar" selector repeated as the first argument of .foo().

        +
        diff --git a/entries/size.xml b/entries/size.xml index e7dd1223..18052147 100644 --- a/entries/size.xml +++ b/entries/size.xml @@ -6,7 +6,9 @@ Return the number of elements in the jQuery object. -

        The .size() method is deprecated as of jQuery 1.8. Use the .length property instead.

        +
        +

        Note: This method has been removed in jQuery 3.0. Use the .length property instead.

        +

        The .size() method is functionally equivalent to the .length property; however, the .length property is preferred because it does not have the overhead of a function call.

        Given a simple unordered list on the page:

        @@ -30,7 +32,7 @@ alert( "Size: " + $( "li" ).length );

        - Count the divs. Click to add more. + Count the divs. - - diff --git a/entries/unload.xml b/entries/unload.xml index 1306ddd6..b57d14f4 100644 --- a/entries/unload.xml +++ b/entries/unload.xml @@ -20,6 +20,9 @@ Bind an event handler to the "unload" JavaScript event. +
        +

        Note: This API has been removed in jQuery 3.0; please use .on( "unload", handler ) instead of .unload( handler ) and .trigger( "unload" ) instead of .unload().

        +

        This method is a shortcut for .on( "unload", handler ).

        The unload event is sent to the window element when the user navigates away from the page. This could mean one of many things. The user could have clicked on a link to leave the page, or typed in a new URL in the address bar. The forward and back buttons will trigger the event. Closing the browser window will cause the event to be triggered. Even a page reload will first create an unload event.

        diff --git a/entries2html.xsl b/entries2html.xsl index fe2dc09b..8237a92f 100755 --- a/entries2html.xsl +++ b/entries2html.xsl @@ -12,7 +12,7 @@ <meta charset="utf-8"> <title> demo</title> <style> </style> - <script src="https://code.jquery.com/jquery-1.10.2.js"></script> + <script src="https://code.jquery.com/jquery-3.4.1.js"></script> <script> </script>