The base2 JavaScript Framework: Bridging Browser Incompatibilities with Standards

Book description

In this Wrox Blox, you'll learn how to program using industry-standard best practices, coving code organization, indention, file structure, and organization. You'll be introduced to the base2 JavaScript framework, which provides a stable backbone for rapid JavaScript application development by bridging and patching cross-browser inconsistencies and idiosyncrasies. This Wrox Blox describes how base2's developer Dean Edwards has made base2's event API consistent and loyal to the W3C standard event API by implementing the standard addEventListener() method in Internet Explorer, thereby providing a standard event API that can be used in all popular, modern browsers.

You will also learn about base2's pioneering support for the W3C Selectors API that was recently natively implemented in Internet Explorer 8.0, Firefox 3.1, Safari 3.0, and Opera 10. base2 utilizes the native implementation when one is present for speed and efficiency and falls back on its own implementation when one is not present.

In addition, you will learn about a couple of methods from base2's rich API set. base2 provides the indexOf() and lastIndexOf() methods for arrays, and provides several other useful enhancements to strings and arrays, such as the forEach() method, which makes enumeration less verbose.

Finally, base2 is even looking forward to the emerging HTML5 draft specification with support for the classList property and its methods, add(), remove(), toggle(), and has(), which let you easily manipulate the class names of elements in the DOM.

  • Programming conventions and best practices

  • Provides tips that will make your markup and JavaScript code appear more polished, organized, and professional.

  • How to make your markup and JavaScript code easier to debug

  • Discusses how you can use base2 to repair and bridge standards support in browsers

  • Describes how you can use the W3C's event API in all modern browsers, including Internet Explorer

  • Covers brand new browser support for the W3C Selectors API, first implemented in JavaScript in base2, now implemented natively in upcoming versions of every major browser, including Internet Explorer 8, Safari 3, Firefox 3.1 and Opera 10

  • Also includes some discussion of base2's support for de facto standards, such as Mozilla's array extras, and the DOMContentLoaded event, which reduce the amount of code you need to write, in addition to making your scripts load more quickly.

Table of contents

  1. Copyright
  2. 1. The base2 JavaScript Framework: Bridging Browser Incompatibilities with Standards
    1. 1.1. Section 1: Programming Conventions
      1. 1.1.1. XHTML and CSS Conventions
        1. Catching Errors in XHTML and CSS
          1. Markup Errors in XHTML and HTML
          2. Errors in CSS
        2. ID and Class Naming Conventions
        3. Generic Type Selectors
        4. Storing and Organizing Files
        5. Avoid Making Documents Inaccessible
        6. Efficiency in Markup and CSS
      2. 1.1.2. JavaScript Conventions
        1. Include All Script in External Documents
        2. Write Clean, Consistent Code
          1. Indenting and Line Length
          2. Control Structures
          3. Optional Curly Braces and Semicolons
          4. Naming Variables, Functions, Objects,...
        3. Namespace JavaScript Code
        4. Avoid Browser Detection
      3. 1.1.3. Summary of Section 1
    2. 1.2. Section 2: Bridging Incompatibilities with base2
      1. 1.2.1. Other JavaScript Frameworks
      2. 1.2.2. Event Standards Provided by base2
      3. 1.2.3. Event-Handling in JavaScript
        1. Assigning an Event with the Traditional Event Model
        2. Assigning Events with the W3C Event Model
          1. The Object this
          2. The event Object
        3. The Microsoft JScript Event Model
      4. 1.2.4. Bridging the Event Compatibility Gap with base2
        1. Downloading base2
        2. Using base2 for the First Time
      5. 1.2.5. The DOMContentLoaded Event
      6. 1.2.6. Summary of Section 2
    3. 1.3. Section 3: Selectors — Not Just for CSS Anymore
      1. 1.3.1. document.querySelector()
      2. 1.3.2. document.querySelectorAll()
      3. 1.3.3. Summary of Section 3
    4. 1.4. Section 4: Other Useful Features of base2
      1. 1.4.1. indexOf() and lastIndexOf()
      2. 1.4.2. forEach()
        1. Silly Rabbit, forEach Is for Arrays, Not Lists
        2. forEach and this
        3. base2's Minor Extension to forEach and Others
      3. 1.4.3. The classList Property
      4. 1.4.4. Summary of Section 4
    5. 1.5. Conclusion
  3. About Richard York

Product information

  • Title: The base2 JavaScript Framework: Bridging Browser Incompatibilities with Standards
  • Author(s): Richard York
  • Release date: October 2008
  • Publisher(s): Wrox Blox
  • ISBN: 9780470422366