diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..eaf18e596 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] + +indent_style = space +indent_size = 2 +charset = utf-8 +insert_final_newline = true +trim_trailing_whitespace = true + +[**/package.json] +indent_size = 2 diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..6ebe4cfa0 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,94 @@ +{ + "env": { + "browser": true, + "node": true, + "amd": true + }, + "globals": { + "attachEvent": false, + "detachEvent": false + }, + "rules": { + "array-bracket-spacing": 2, + "block-scoped-var": 2, + "brace-style": [1, "1tbs", {"allowSingleLine": true}], + "camelcase": 2, + "comma-dangle": [2, "never"], + "comma-spacing": 2, + "computed-property-spacing": [2, "never"], + "dot-notation": [2, { "allowKeywords": false }], + "eol-last": 2, + "eqeqeq": [2, "smart"], + "indent": [2, 2, { + "MemberExpression": 0, + "SwitchCase": 1, + "VariableDeclarator": 2 + }], + "key-spacing": 1, + "keyword-spacing": [2, { "after": true }], + "linebreak-style": 2, + "max-depth": [1, 4], + "max-params": [1, 5], + "new-cap": [2, {"newIsCapExceptions": ["model"]}], + "no-alert": 2, + "no-caller": 2, + "no-catch-shadow": 2, + "no-console": 2, + "no-debugger": 2, + "no-delete-var": 2, + "no-div-regex": 1, + "no-dupe-args": 2, + "no-dupe-keys": 2, + "no-duplicate-case": 2, + "no-else-return": 1, + "no-empty-character-class": 2, + "no-eval": 2, + "no-ex-assign": 2, + "no-extend-native": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": 1, + "no-extra-semi": 2, + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-func-assign": 2, + "no-implied-eval": 2, + "no-inner-declarations": 2, + "no-irregular-whitespace": 2, + "no-label-var": 2, + "no-labels": 2, + "no-lone-blocks": 2, + "no-lonely-if": 2, + "no-multi-str": 2, + "no-native-reassign": 2, + "no-negated-in-lhs": 1, + "no-new-object": 2, + "no-new-wrappers": 2, + "no-obj-calls": 2, + "no-octal": 2, + "no-octal-escape": 2, + "no-proto": 2, + "no-redeclare": 2, + "no-shadow": 2, + "no-spaced-func": 2, + "no-throw-literal": 2, + "no-trailing-spaces": 2, + "no-undef": 2, + "no-undef-init": 2, + "no-undefined": 2, + "no-unneeded-ternary": 2, + "no-unreachable": 2, + "no-unused-expressions": [2, {"allowTernary": true, "allowShortCircuit": true}], + "no-with": 2, + "object-curly-spacing": [2, "never"], + "quote-props": [1, "consistent-as-needed", {"keywords": true}], + "quotes": [2, "single", "avoid-escape"], + "radix": 2, + "semi": 2, + "space-before-function-paren": [2, {"anonymous": "never", "named": "never"}], + "space-infix-ops": 2, + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "use-isnan": 2, + "valid-typeof": 2, + "wrap-iife": [2, "inside"] + } +} diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..9913f95a8 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +tidelift: "npm/backbone" +patreon: juliangonggrijp +github: [jgonggrijp] diff --git a/.github/ISSUE_TEMPLATE/Bugs.yml b/.github/ISSUE_TEMPLATE/Bugs.yml new file mode 100644 index 000000000..544ded0d1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bugs.yml @@ -0,0 +1,173 @@ +name: Bug report +description: | + Report something that is not working correctly. + Not intended for security issues! +title: Foo.bar should bazoonite, but frobulates instead +body: + - type: markdown + attributes: + value: " + Thank you for taking the effort to report a bug.\n\n + + Is your bug a security issue? In that case, **please do not use this + form!** Instead, see the [security + policy](https://github.com/jashkenas/backbone/security/policy) on how to + report the issue.\n\n + + ## Identification\n\n + + To start, some quick questions to pinpoint the issue." + - type: input + id: component + attributes: + label: Affected component + description: > + Which part of Backbone is affected? Please be as specific as possible, + for example “the silent option of Collection.reset” or + “importing Backbone with require.js”. + placeholder: the sync event triggered after Model.fetch + validations: + required: true + - type: input + id: expected + attributes: + label: Expected behavior + description: | + In one sentence, what *should* the affected component do? + placeholder: | + Forward all options passed to Model.fetch to the event handler + validations: + required: true + - type: input + id: actual + attributes: + label: Actual behavior + description: | + In one sentence, what does the affected component *actually* do? + placeholder: | + Forward options to the method called last, e.g. save. + validations: + required: true + - type: markdown + attributes: + value: " + After filling the above three fields, please review the issue title. It + should be short, including elements of all three fields and not much + else.\n\n + + For example: **After Model.fetch, sync event may include + options of a later sync, save or destroy call**\n\n + + ## Context" + - type: textarea + id: docs + attributes: + label: Relevant documentation + description: | + Which documentation, if any, did you base your above expectation on? + Provide one link per line. + placeholder: | + - https://backbonejs.org/#Model-fetch + - https://backbonejs.org/#Events-catalog + - type: textarea + id: stack + attributes: + label: Software stack + description: " + With which version(s) of Backbone, Underscore/Lodash, jQuery/Zepto, + other relevant libraries or tools, your browser, etcetera, did you + experience this problem? Please list one per line, including name, + version number(s) and variant(s) if applicable.\n\n + + **Tip:** if you are using the bleeding-edge version of + Backbone, much of this information can be obtained by using + [debugInfo](https://backbonejs.org/#Utility-Backbone-debugInfo) + and copy-pasting its console output below." + placeholder: " + - Backbone 1.4.1 and latest `master` (commit fcf5df6)\n + - Underscore 1.13.6\n + - jQuery 3.6.3 (slim build)\n + - Marionette 4.1.2\n + - Firefox 100\n + - Node.js 14.6\n + + OR (stretch form field to see example content):\n + + ```json\n + Backbone debug info: {\n + \ \ \"backbone\": \"1.5.0\",\n + \ \ \"distribution\": \"MARK_DEVELOPMENT\",\n + \ \ \"_\": \"lodash 4.17.21\",\n + \ \ \"$\": \"3.6.0\",\n + \ \ \"navigator\": {\n + \ \ \ \ \"userAgent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/116.0\",\n + \ \ \ \ \"platform\": \"MacIntel\",\n + \ \ \ \ \"webdriver\": false\n + \ \ }\n + }\n + ```\n + + - Backbone `master` checked out on August 10, 2023\n + - Marionette 4.1.2" + validations: + required: true + - type: textarea + id: discourse + attributes: + label: Related issues, prior discussion and CCs + description: > + Please list any issue numbers, pull requests or links to discussions + elsewhere on the internet that may be relevant. You can also attract the + attention of other GitHub users by listing their `@handles` here. + placeholder: " + #4229, #3410\n + a Stack Overflow or Matrix link\n + @jgonggrijp" + - type: markdown + attributes: + value: "## Bug details" + - type: input + id: error + attributes: + label: Error + description: > + If possible, name the error that you observed and that anyone trying to + reproduce the bug should look for. + placeholder: TypeError (options.success is not an object) + - type: textarea + id: repro + attributes: + label: Steps to reproduce + description: > + List the minimal steps needed to make the bug happen. Include code + examples as needed. + validations: + required: true + - type: textarea + id: details + attributes: + label: Additional information + description: >- + This is a free-form field where you can add any further details that may + help to understand the bug. For example, you might provide permalinks to + the affected lines of code in your actual project, attach logs or + screenshots, point out things you noticed while debugging, and explain + why the bug is especially problematic for your use case. + - type: markdown + attributes: + value: "## Closing" + - type: textarea + id: solution + attributes: + label: Suggested solution(s) + description: > + If you have any idea on how the problem could (or should) be solved, + please feel welcome to describe it here. Of course, if your idea is very + concrete, you may as well submit a pull request! + - type: textarea + id: remarks + attributes: + label: Other remarks + description: >- + If there is anything else you would like to say about the issue, you can + do so here. diff --git a/.github/ISSUE_TEMPLATE/Documentation.yml b/.github/ISSUE_TEMPLATE/Documentation.yml new file mode 100644 index 000000000..fc6ea8bc4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Documentation.yml @@ -0,0 +1,76 @@ +name: Documentation issue +description: >- + Report information that is missing, incomplete, vague, misleading or plain + wrong in online documentation such as the website, the README, the wiki, + etcetera. +body: + - type: markdown + attributes: + value: >- + Thank you for taking the time to help us improve the documentation. + - type: input + id: reference + attributes: + label: Reference to current documentation + description: >- + If you can identify an existing piece of documentation that is lacking, + please provide a URL (or multiple) below. If your report is about + missing information and there is no single obvious place where it should + be added, you can leave this empty. + placeholder: "https://backbonejs.org/#Model-changedAttributes" + - type: textarea + id: quote + attributes: + label: Quote of current documentation + description: >- + If you provided a URL in the previous field, please quote the + problematic documentation below. This ensures that future readers + understand what you were responding to, in case the referred page + disappears or changes content. + placeholder: " + > Retrieve a hash of only the model's attributes that have changed since + the last + [set](https://backbonejs.org/#Model-set), or `false` if there are none. + Optionally, an external **attributes** hash can be passed in, returning + the attributes in that hash which differ from the model. This can be + used to figure out which portions of a view should be updated, or what + calls need to be made to sync the changes to the server." + - type: textarea + id: effect + attributes: + label: Effect of the problem + description: >- + What did you or someone else not know, misunderstand or falsely believe + due to the current state of the documentation? How has this misguided + your or someone else's behavior? + placeholder: >- + I did not know that I could ..., so I needlessly ... + validations: + required: true + - type: textarea + id: cause + attributes: + label: Cause of the problem + description: >- + What is it about the current documentation that caused your problem? + What is missing, ambiguous or wrong? Pinpoint specific words or phrases + if possible. + placeholder: >- + It says "...", which seems to suggest that ..., while actually, ... + validations: + required: true + - type: textarea + id: suggestion + attributes: + label: Suggestion + description: >- + If you have any idea on how the documentation could be improved, please + share it here. Of course, if your idea is very concrete, you can also + submit a pull request! + - type: textarea + id: remarks + attributes: + label: Other remarks + description: >- + If there is anything else you would like to say about the issue, you can + do so here. diff --git a/.github/ISSUE_TEMPLATE/Features.yml b/.github/ISSUE_TEMPLATE/Features.yml new file mode 100644 index 000000000..1bcb1a2a1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Features.yml @@ -0,0 +1,72 @@ +name: Feature request +description: >- + Tell us about functionality that you miss in Backbone. +body: + - type: markdown + attributes: + value: | + Thank you for proposing a new feature. + + Let us begin with the end in mind. + - type: textarea + id: goal + attributes: + label: Ultimate goal + description: >- + This first question is not about Backbone but about the mission that you + hope to accomplish with Backbone. What work do you need to get done? + placeholder: | + GOOD: I work on an application that needs to ... + BAD (later question): I think Backbone.Collection should have a method that ... + validations: + required: true + - type: textarea + id: shortcoming + attributes: + label: Shortcomings + description: >- + Working towards your end goal, what task is currently difficult to + achieve with Backbone as it is? Which features in Backbone or other + libraries are currently available to you, which do not quite do what you + need? + placeholder: | + In my application, I need to ..., but when I define a + Backbone.Collection subclass, there does not seem to be any way to ... + + - I could use `Collection.slice`, but ... + - I could use , but ... + validations: + required: true + - type: textarea + id: justification + attributes: + label: Justification + description: >- + Why do you believe that the missing functionality belongs in Backbone + proper? Why could or should it not be provided by another library or + tool? + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Proposal + description: >- + Go ahead, describe your ideal solution. Show what it should look like + and explain how it should behave. + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Possible alternatives + description: >- + Can you think of other ways in which your desired functionality could be + provided? If they appeal less to you, why is this the case? + - type: textarea + id: remarks + attributes: + label: Other remarks + description: >- + If there is anything else you would like to say about your feature + request, you can do so here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..49b03e819 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,10 @@ +contact_links: + - name: Security issue + url: https://github.com/jashkenas/backbone/security/policy + about: Go here if you would like to report a security issue. + - name: Stack Overflow + url: https://stackoverflow.com/questions/tagged/backbone.js + about: The best place to get help making your code work (be sure to include the `backbone.js` tag). + - name: Matrix/Gitter + url: https://matrix.to/#/#jashkenas_backbone:gitter.im + about: Discussions about, and general help with, Backbone. diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..70c3f3d5f --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,37 @@ +name: Test + +on: + push: + branches: + - master + pull_request: + branches: + - master + paths: + - '.github/workflows/**' + - 'test/**' + - '*.js' + - 'package.json' + +jobs: + tests: + env: + NPM_CONFIG_PROGRESS: "false" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 16 + cache: 'npm' + - name: Install dependencies + run: | + npm ci + npm install --no-audit karma-cli karma-sauce-launcher + - name: Test in Sauce Labs + run: BUILD_NUMBER="$GITHUB_RUN_NUMBER" BUILD_ID="$GITHUB_RUN_ID" JOB_NUMBER="$GITHUB_JOB" ./node_modules/.bin/karma start karma.conf-sauce.js + env: + SAUCE_USERNAME: ${{ secrets.SauceUsername }} + SAUCE_ACCESS_KEY: ${{ secrets.SauceAccessKey }} diff --git a/.gitignore b/.gitignore index 232978d0c..bb763e1f9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ raw *.sw? .DS_Store node_modules +bower_components diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 6bcb69f50..000000000 --- a/.npmignore +++ /dev/null @@ -1,7 +0,0 @@ -test/ -Rakefile -docs/ -raw/ -examples/ -index.html -.jshintrc diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 99dc7712c..000000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: - - 0.8 -notifications: - email: false diff --git a/CNAME b/CNAME index dfadb7985..706ffc0a0 100644 --- a/CNAME +++ b/CNAME @@ -1,2 +1 @@ -backbonejs.org - +backbonejs.org \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..7b0aa10b8 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,155 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +jashkenas@gmail.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Moderation + +Edits of another user's comment must be clearly marked with "**edit**", the +moderator's username, and a timestamp for each occurrence. The only acceptable +reasons for editing another user's comment are: + +1. to edit out violations of Our Pledge. These edits must include a rationale. +2. to direct future readers to a relevant point later in the conversation + (usually the resolution). These edits must be append-only. + +Deletion of another user's comment is only acceptable when the comment includes +no original value, such as "+1", ":+1:", or "me too". + +## Self-Moderation + +Edits of your own comment after someone has responded must be append-only and +clearly marked with "**edit**". Typographical and formatting fixes to your own +comment which do not affect its meaning are exempt from this requirement. +Deletion of your own comment is only acceptable before any later comments have +been posted. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 55403616b..74a419b36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,8 @@ ## How to Open a Backbone.js Ticket * Do not use tickets to ask for help with (debugging) your application. Ask on -the [mailing list](https://groups.google.com/forum/#!forum/backbonejs), -in the IRC channel (`#documentcloud` on Freenode), or if you understand your +the [mailing list](https://groups.google.com/forum/#!forum/backbonejs), +in the IRC channel (`#documentcloud` on Freenode), or if you understand your specific problem, on [StackOverflow](http://stackoverflow.com/questions/tagged/backbone.js). * Before you open a ticket or send a pull request, @@ -11,12 +11,13 @@ discussions about the same feature or issue. Add to the earlier ticket if you find one. * Before sending a pull request for a feature or bug fix, be sure to have -[tests](http://backbonejs.org/test/). +[tests](http://backbonejs.org/test/) and to document any new functionality in +the `index.html`. * Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/backbone/blob/master/backbone.js). -* In your pull request, do not add documentation or rebuild the minified -`backbone-min.js` file. We'll do that before cutting a new release. +* In your pull request, do not regenerate the annotated sources or rebuild the +minified `backbone-min.js` file. We'll do that before cutting a new release. * All pull requests should be made to the `master` branch. diff --git a/LICENSE b/LICENSE index dda0a5809..79cad384d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010-2013 Jeremy Ashkenas, DocumentCloud +Copyright (c) 2010-2024 Jeremy Ashkenas, DocumentCloud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.md b/README.md index 7b0482df7..0854baf69 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,30 @@ (_.———————————————————————————————————————————————————————————————————————————————._) -Backbone supplies structure to JavaScript-heavy applications by providing models key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface. +Backbone supplies structure to JavaScript-heavy applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface. For Docs, License, Tests, pre-packed downloads, and everything else, really, see: -http://backbonejs.org +https://backbonejs.org -To suggest a feature, report a bug, or general discussion: -http://github.com/jashkenas/backbone/issues +To suggest a feature or report a bug: +https://github.com/jashkenas/backbone/issues + +For questions on working with Backbone or general discussions: +[security policy](SECURITY.md), +https://stackoverflow.com/questions/tagged/backbone.js, +https://matrix.to/#/#jashkenas_backbone:gitter.im or +https://groups.google.com/g/backbonejs Backbone is an open-sourced component of DocumentCloud: https://github.com/documentcloud +Testing powered by SauceLabs: +https://saucelabs.com + Many thanks to our contributors: -http://github.com/jashkenas/backbone/contributors +https://github.com/jashkenas/backbone/graphs/contributors Special thanks to Robert Kieffer for the original philosophy behind Backbone. -http://github.com/broofa +https://github.com/broofa + +This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..28329ed28 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,38 @@ +# Security Policy + +## Supported Versions + +We currently support the following versions of Backbone with security updates: + +- the latest commit on the `master` branch (published as "edge" on the + [project website][website]); +- the 1.x release tagged as [latest][npm-latest] on npm; +- any release tagged as [preview][npm-preview] on npm, if present. + +[website]: https://backbonejs.org +[npm-latest]: https://www.npmjs.com/package/backbone/v/latest +[npm-preview]: https://www.npmjs.com/package/backbone/v/preview + +## Reporting a Vulnerability + +Please report security issues by sending an email to +dev@juliangonggrijp.com and jashkenas@gmail.com. + +Do __not__ submit an issue ticket or pull request or otherwise publicly +disclose the issue. + +After receiving your email, we will respond as soon as possible and indicate +what we plan to do. + +## Disclosure policy + +After confirming a vulnerability, we will generally release a security update +as soon as possible, including the minimum amount of information required for +software maintainers and system administrators to assess the urgency of the +update for their particular situation. + +We postpone the publication of any further details such as code comments, +tests, commit history and diffs, in order to enable a substantial share of the +users to install the security fix before this time. + +Upon publication of full details, we will credit the reporter if the reporter wishes to be publicly identified. diff --git a/backbone-min.js b/backbone-min.js index 3b2593dd2..092b984fe 100644 --- a/backbone-min.js +++ b/backbone-min.js @@ -1,2 +1,2 @@ -(function(){var t=this;var e=t.Backbone;var i=[];var r=i.push;var s=i.slice;var n=i.splice;var a;if(typeof exports!=="undefined"){a=exports}else{a=t.Backbone={}}a.VERSION="1.1.0";var h=t._;if(!h&&typeof require!=="undefined")h=require("underscore");a.$=t.jQuery||t.Zepto||t.ender||t.$;a.noConflict=function(){t.Backbone=e;return this};a.emulateHTTP=false;a.emulateJSON=false;var o=a.Events={on:function(t,e,i){if(!l(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,i){if(!l(this,"once",t,[e,i])||!e)return this;var r=this;var s=h.once(function(){r.off(t,s);e.apply(this,arguments)});s._callback=e;return this.on(t,s,i)},off:function(t,e,i){var r,s,n,a,o,u,c,f;if(!this._events||!l(this,"off",t,[e,i]))return this;if(!t&&!e&&!i){this._events={};return this}a=t?[t]:h.keys(this._events);for(o=0,u=a.length;o").attr(t);this.setElement(e,false)}else{this.setElement(h.result(this,"el"),false)}}});a.sync=function(t,e,i){var r=T[t];h.defaults(i||(i={}),{emulateHTTP:a.emulateHTTP,emulateJSON:a.emulateJSON});var s={type:r,dataType:"json"};if(!i.url){s.url=h.result(e,"url")||U()}if(i.data==null&&e&&(t==="create"||t==="update"||t==="patch")){s.contentType="application/json";s.data=JSON.stringify(i.attrs||e.toJSON(i))}if(i.emulateJSON){s.contentType="application/x-www-form-urlencoded";s.data=s.data?{model:s.data}:{}}if(i.emulateHTTP&&(r==="PUT"||r==="DELETE"||r==="PATCH")){s.type="POST";if(i.emulateJSON)s.data._method=r;var n=i.beforeSend;i.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",r);if(n)return n.apply(this,arguments)}}if(s.type!=="GET"&&!i.emulateJSON){s.processData=false}if(s.type==="PATCH"&&E){s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var o=i.xhr=a.ajax(h.extend(s,i));e.trigger("request",e,o,i);return o};var E=typeof window!=="undefined"&&!!window.ActiveXObject&&!(window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent);var T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};a.ajax=function(){return a.$.ajax.apply(a.$,arguments)};var k=a.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var S=/\((.*?)\)/g;var $=/(\(\?)?:\w+/g;var H=/\*\w+/g;var A=/[\-{}\[\]+?.,\\\^$|#\s]/g;h.extend(k.prototype,o,{initialize:function(){},route:function(t,e,i){if(!h.isRegExp(t))t=this._routeToRegExp(t);if(h.isFunction(e)){i=e;e=""}if(!i)i=this[e];var r=this;a.history.route(t,function(s){var n=r._extractParameters(t,s);i&&i.apply(r,n);r.trigger.apply(r,["route:"+e].concat(n));r.trigger("route",e,n);a.history.trigger("route",r,e,n)});return this},navigate:function(t,e){a.history.navigate(t,e);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=h.result(this,"routes");var t,e=h.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(A,"\\$&").replace(S,"(?:$1)?").replace($,function(t,e){return e?t:"([^/]+)"}).replace(H,"(.*?)");return new RegExp("^"+t+"$")},_extractParameters:function(t,e){var i=t.exec(e).slice(1);return h.map(i,function(t){return t?decodeURIComponent(t):null})}});var I=a.History=function(){this.handlers=[];h.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var N=/^[#\/]|\s+$/g;var O=/^\/+|\/+$/g;var P=/msie [\w.]+/;var C=/\/$/;var j=/[?#].*$/;I.started=false;h.extend(I.prototype,o,{interval:50,getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=this.location.pathname;var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.slice(i.length)}else{t=this.getHash()}}return t.replace(N,"")},start:function(t){if(I.started)throw new Error("Backbone.history has already been started");I.started=true;this.options=h.extend({root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var e=this.getFragment();var i=document.documentMode;var r=P.exec(navigator.userAgent.toLowerCase())&&(!i||i<=7);this.root=("/"+this.root+"/").replace(O,"/");if(r&&this._wantsHashChange){this.iframe=a.$('