Bug Tracker

Opened 9 years ago

Closed 9 years ago

#15208 closed bug (duplicate)

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);

Change History (7)

comment:1 Changed 9 years ago by Rick Waldron

Resolution: wontfix
Status: newclosed

comment:2 in reply to:  1 Changed 9 years ago by Michael

Replying to 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();

})();

comment:3 Changed 9 years ago by Rick Waldron

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.

comment:4 in reply to:  3 Changed 9 years ago by Michael

Replying to 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

comment:5 Changed 9 years ago by Rick Waldron

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

comment:6 Changed 9 years ago by Rick Waldron

Resolution: wontfix
Status: closedreopened

comment:7 Changed 9 years ago by Rick Waldron

Resolution: duplicate
Status: reopenedclosed

Duplicate of #2721.

Note: See TracTickets for help on using tickets.