Skip to main content

Bug Tracker

Side navigation

#15208 closed bug (duplicate)

Opened August 09, 2014 03:34PM UTC

Closed August 10, 2014 01:10AM UTC

jQuery.extend

Reported by: Michael Owned by:
Priority: high Milestone:
Component: core Version:
Keywords: Cc:
Blocked by: Blocking:
Description

File: index.hmtl

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Test for jQuery.extend</title>
  </head>
  <body>
    <script src="MyLibrary.js" type="text/javascript"></script>
    <script src="//cdn.jsdelivr.net/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
  </body>
</html>

File: MyLibrary.js

(function (document) {

  // region To Debug

  function debug(text, args) {
    for (var buffer = [], count = args.length, index = 0; index < count; )
      buffer.push(args[index++]);
    if (count)
      text += '\\n' + buffer.join('\\n');
    document.body.appendChild(document.createElement('pre')).innerHTML = text
  }

  // endregion

  // region MyLibrary extensions

  // Static extension: Object.extend(target: Object, source: Object, ...): Object
  Object.extend = function () {
    debug('Object.extend is called', arguments)
  };

  // Instance extension: ({ ... }).extend(source: Object, ...): Object
  Object.prototype.extend = function () {
    debug('Object.prototype.extend is called', arguments)
  };

  // endregion

})(document);
Attachments (0)
Change History (7)

Changed August 09, 2014 06:09PM UTC by rwaldron comment:1

resolution: → wontfix
status: newclosed

Changed August 09, 2014 08:08PM UTC by Michael comment:2

Replying to [comment:1 rwaldron]:

http://contribute.jquery.org/wont-fix/

It's an excuse only. See code below.

File: index.hmtl (modified)

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Test for jQuery.extend</title>
  </head>
  <body>
    <script src="MyLibrary.js" type="text/javascript"></script>
    <script src="MyLibraryPlus.js" type="text/javascript"></script>
    <script src="MyLibraryTest.js" type="text/javascript"></script>
    <script src="//cdn.jsdelivr.net/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
  </body>
</html>

File: MyLibraryPlus.js (extend overloading)

(function (document) {

  // region To Debug

  function debug(text) {
    document.body.appendChild(document.createElement('pre')).innerHTML = text
  }

  // endregion

  var MyQuery = (window || this).MyQuery = function () {
  };

  MyQuery.extend = function () {
    debug('static MyQuery.extend is called')
  };

  MyQuery.prototype.extend = function () {
    debug('instance MyQuery.extend is called')
  };

})(document);

File: MyLibraryTest.js (tests for extend)

(function () {

  MyQuery.extend();
  new MyQuery().extend();

})();

Changed August 09, 2014 09:01PM UTC by rwaldron comment:3

It's unclear what bug you're trying to report. Please follow the instructions displayed on the bug filing page and provide a fiddle http://jsfiddle.net/ that demonstrates the most reduced case. Additional explanation helps as well.

Changed August 10, 2014 12:17AM UTC by Michael comment:4

Replying to [comment:3 rwaldron]:

It's unclear what bug you're trying to report. Please follow the instructions displayed on the bug filing page and provide a fiddle http://jsfiddle.net/ that demonstrates the most reduced case. Additional explanation helps as well.

Ok, see this demo at jsFiddle: jsFiddle.Net/Michael Bryzgalov

Changed August 10, 2014 01:03AM UTC by rwaldron comment:5

It's still unclear what bug you're trying to report. Anything to do with extending native Objects is out of scope for jQuery.

Changed August 10, 2014 01:09AM UTC by rwaldron comment:6

resolution: wontfix
status: closedreopened

Changed August 10, 2014 01:10AM UTC by rwaldron comment:7

resolution: → duplicate
status: reopenedclosed

Duplicate of #2721.