Permalink
Browse files

Added Dom Level 3 methods to browser augmentation for jQuery support …

…as standard. Cleaned up examples to match.
  • Loading branch information...
1 parent 65be3bd commit bef53ad85e57d975b28f9ee724b6396721332945 Jos Shepherd committed Jun 16, 2010
Showing with 12 additions and 15 deletions.
  1. +2 −6 {lib → example}/browser/browser.js
  2. +4 −8 example/jquery/run.js
  3. +1 −1 example/pure/run.js
  4. +5 −0 lib/browser/index.js
@@ -1,18 +1,15 @@
var sys = require('sys');
-
-var dom = require('../level1/core').dom.level1.core;
-var browser = require('./index').windowAugmentation(dom);
-
+var dom = require('../../lib/level1/core').dom.level1.core;
+var browser = require('../../lib/browser/index').windowAugmentation(dom);
var document = browser.document;
var window = browser.window;
var self = browser.self;
var navigator = browser.navigator;
var location = browser.location;
-
document.title = 'Test Title';
//GLOBAL
@@ -21,7 +18,6 @@ el.id = 'foo';
el.innerHTML = '<em>This is a test</em> This <strong class="odd">is another</strong> test ';
document.body.appendChild(el);
-
//SCOPED
var el2 = browser.document.createElement('div');
el2.id = 'foo2bar';
View
@@ -1,16 +1,12 @@
-var sys = require("sys"),
- dom = require(__dirname +"/../../lib/level1/core").dom.level1.core,
- fs = require("fs");
+var sys = require("sys"), fs = require("fs");
-var window = require(__dirname + "/../../lib/browser").windowAugmentation(dom);
+var dom = require("../../lib/level1/core").dom.level1.core;
+var window = require("../../lib/browser").windowAugmentation(dom).window;
var document = window.document;
var location = window.location;
-var navigator = window.navigator = { userAgent: "node-js" };
-global.window = window;
+var navigator = window.navigator;
fs.readFile(__dirname + "/jquery.js", function(err, data) {
- global.window.document.compareDocumentPosition = function() {};
- dom.Node.prototype.addEventListener = window.addEventListener = window.document.addEventListener = function() {};
try {
eval(data.toString());
View
@@ -4,7 +4,7 @@ var sax = require("./sax");
var sys = require("sys");
-
+// TODO: change this example to use pluggable parser
/**
setup innerHTML setter
View
@@ -43,6 +43,9 @@ exports.windowAugmentation = function(dom, options) {
Window.addEventListener2 = function(type, fn, capture) {
fn.apply(Window);
};
+ Window.document.compareDocumentPosition = function() {};
+ Window.addEventListener = function() {};
+ Window.document.addEventListener = function() {};
var html = Window.document.createElement('html');
Window.document.appendChild(html);
@@ -93,6 +96,8 @@ var browserAugmentation = exports.browserAugmentation = function(dom, options) {
* Browser Augmentation *
***************************************/
+ dom.Node.prototype.addEventListener = function(){};
+
dom.Element.prototype.getElementsByClassName = function(className) {
var queryFunction = function(child) {

0 comments on commit bef53ad

Please sign in to comment.