Code Monkey home page Code Monkey logo

better-dom's Introduction

better-dom Build Status Coverage Status

Live extension playground

jQuery knows a concept called “live events”. Using the idea of event delegation they enabled developers to handle existing and future elements. But more flexibility is required in a lot of cases. For example, delegated events fall short when the DOM needs to be mutated in order to initialize a widget. To handle such cases I'd like to introduce live extensions and better-dom - a new library for working with the DOM.

API DOCUMENTATION

Quick start

I'd recommend to read one from the articles below to understand the main ideas of the library:

Features

Installation

The simplest way is to use bower:

bower install better-dom

This will clone the latest version of the better-dom with dependencies into the bower_components directory at the root of your project. Then just include scripts below on your web page:

<!DOCTYPE html>
<html>
<head>
    ...
    <!--[if IE]>
        <link href="bower_components/better-dom/dist/better-dom-legacy.htc" rel="htc"/>
        <script src="bower_components/better-dom/dist/better-dom-legacy.js"></script>
    <![endif]-->
</head>
<body>
    ...
    <script src="bower_components/better-dom/dist/better-dom.js"></script>
</body>
</html>

Documentation

Performance

How to make a custom build

In order to create a custom build make sure that you installed grunt-cli globally:

npm install -g grunt-cli

Then you can print all available modules for customization via the default task:

grunt

To create a full build run build task without arguments:

grunt build

Your build will be created inside of the build folder including uglified version with source maps. Pick modules that you want to exclude and pass them to the same task separated by comma:

grunt build:classes,offset,traversing

Look at the API documentation to find which functions are included into a particular module (see Modules menu).

Notes about old IEs

For IE8-9 support you have to incude extra files via conditional comment (see Installation section).

The better-dom-legacy.js file includes excellent html5shiv that provides fix for HTML5 tags and es5-shim is used to polyfill missed standards-based functions. These projects are bundled into signle file with other fixes.

The better-dom-legacy.htc file helps to implement live extensions support. This fact applies several important limitations that you must know in case when legacy browser support is required.

Setup content-type header

HTC behaviors have to serve up with a content-type header of “text/x-component”, otherwise IE will simply ignore the file. Many web servers are preconfigured with the correct content-type, but others are not.

AddType text/x-component .htc

Same domain limitation

IE requires that the HTC file must be in the same domain with as the HTML page which uses it. If you try to load the behavior from a different domain, you will get an “Access Denied” error.

Browser support

Desktop

  • Chrome
  • Safari 6.0+
  • Firefox 16+
  • Opera 12.10+
  • IE8+

Mobile

  • iOS Safari 6+
  • Android 2.3+
  • Chrome for Android

Opera Mini is out of the scope because of lack of support for CSS3 Animations.

better-dom's People

Contributors

chemerisuk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.