Skip to content

Latest commit

 

History

History
130 lines (96 loc) · 4.31 KB

File metadata and controls

130 lines (96 loc) · 4.31 KB

jquery

This file provides context for AI coding assistants working with this repository.

Repository Overview

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversing and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.

Tech Stack: JavaScript, HTML

This repository contains the core jQuery library, which is designed to be used in browser environments but also supports Node.js, browser extensions, and other non-browser environments.

Build System

The build system for jQuery uses npm and Grunt.

Key commands:

  • npm install: Install dependencies
  • npm run build: Build jQuery (equivalent to grunt)
  • grunt: Build a full version of jQuery
  • grunt -help: List all available Grunt tasks

Essential Workflows

Initial Setup

  1. Ensure you have Node.js/npm and git 1.7 or later installed.
  2. Clone the repository:
    git clone git://github.com/jquery/jquery.git
  3. Enter the jquery directory:
    cd jquery
  4. Install dependencies:
    npm install
  5. Install Grunt CLI globally (recommended):
    npm install -g grunt-cli

Making Code Changes

  1. Make your changes in the src/ directory.
  2. Run grunt to build jQuery.
  3. The built version will be in the dist/ subdirectory.

Running Tests

To run tests:

npm test

This command runs Grunt and then executes the test suite.

Adding Dependencies

Add new dependencies to package.json and then run npm install.

Project Structure

jquery/
  ├─ build/            # Build-related files
  ├─ external/         # External libraries and tools
  ├─ src/              # Source code for jQuery
  │  ├─ ajax/          # AJAX functionality
  │  ├─ attributes/    # Attribute manipulation
  │  ├─ core/          # Core jQuery functionality
  │  ├─ css/           # CSS manipulation
  │  ├─ data/          # Data storage
  │  ├─ effects/       # Animation and effects
  │  ├─ event/         # Event handling
  │  ├─ manipulation/  # DOM manipulation
  │  ├─ traversing/    # DOM traversal
  │  └─ ...
  ├─ test/             # Test files (not visible in provided tree)
  └─ dist/             # Built files (created after build)

Critical Patterns

  • Modular structure: jQuery is organized into modules (ajax, attributes, core, etc.) for maintainability.
  • Use of immediate function invocations for scoping.
  • Extensive use of method chaining in the API design.
  • Cross-browser compatibility considerations throughout the codebase.

Common Pitfalls to Avoid

  • Ensure you're using the latest Node.js version for compatibility.
  • Run grunt after making changes to rebuild jQuery.
  • When creating custom builds, be aware of module dependencies (e.g., excluding 'css' will remove all modules depending on it).
  • Contribute to the correct repository: this is for jQuery Core only, not plugins or documentation.

Testing Philosophy

jQuery uses QUnit for testing. Test files are organized to match the structure of the src/ directory. The project emphasizes thorough testing, with tests for both API functionality and internal implementations.

CI/CD

The repository uses Travis CI for continuous integration. The .travis.yml file (not visible in the provided tree) likely contains the CI configuration.

Security Guidelines (CRITICAL - Forter Standards)

Must Follow:

  • NEVER hardcode secrets, API keys, or credentials
  • NEVER log sensitive data (PII, tokens, passwords)
  • NEVER commit .env files or secrets
  • [OK] Use environment variables for all secrets
  • [OK] Validate and sanitize all user inputs
  • [OK] Follow the principle of least privilege

Additionally for jQuery:

  • Sanitize all inputs when manipulating the DOM to prevent XSS attacks.
  • Use .text() instead of .html() when inserting user-generated content.
  • Be cautious when using $.ajax() to prevent CSRF vulnerabilities.

Before Committing

  1. Run linting: grunt jshint
  2. Run tests: npm test
  3. Build: grunt
  4. Verify: Check that your changes don't break existing functionality and follow the jQuery Core Style Guide.

Generated by Forter AI Platform