forked from davglass/nodejs-yui3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
y-browser.js
executable file
·95 lines (77 loc) · 2.89 KB
/
y-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env node
var sys = require('sys'),
YUI = require("yui3").YUI;
YUI({
filter: 'debug',
_logExclude: {
'attribute': true,
'base': true,
'get': true,
'loader': true,
'yui': true,
'widget': true,
'event': true
},
debug: false
}).use('nodejs-dom', 'node', function(Y) {
var document = Y.Browser.document;
var window = Y.Browser.window;
var self = Y.Browser.self;
var navigator = Y.Browser.navigator;
var location = Y.Browser.location;
document.title = 'Example #1';
//With the local aliases
var el = document.createElement('div');
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 = Y.Browser.document.createElement('div');
el2.id = 'foo2bar';
el2.innerHTML = '<em class="odd">This is a test</em> This <strong>is another</strong> test ';
Y.Browser.document.body.appendChild(el2);
sys.puts('getElementByid(foo2bar): ' + Y.Browser.document.getElementById('foo2bar'));
sys.puts('getElementByid(foo): ' + Y.Browser.document.getElementById('foo'));
sys.puts('getElementByTagName(em): ' + Y.Browser.document.getElementsByTagName('em'));
sys.puts('getElementByClassName(odd): ' + Y.Browser.document.getElementsByClassName('odd'));
sys.puts('');
sys.puts('Y.Browser.document.outerHTML: ');
sys.puts(Y.Browser.document.outerHTML);
});
YUI({
filter: 'debug',
_logExclude: {
'attribute': true,
'base': true,
'get': true,
'loader': true,
'yui': true,
'widget': true,
'event': true
},
debug: false
}).use('nodejs-dom', 'node', function(Y) {
var document = Y.Browser.document;
var window = Y.Browser.window;
var self = Y.Browser.self;
var navigator = Y.Browser.navigator;
var location = Y.Browser.location;
document.title = 'Example #2';
//With the local aliases
var el = document.createElement('div');
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 = Y.Browser.document.createElement('div');
el2.id = 'foo2bar';
el2.innerHTML = '<em class="odd">This is a test</em> This <strong>is another</strong> test ';
Y.Browser.document.body.appendChild(el2);
sys.puts('getElementByid(foo2bar): ' + Y.Browser.document.getElementById('foo2bar'));
sys.puts('getElementByid(foo): ' + Y.Browser.document.getElementById('foo'));
sys.puts('getElementByTagName(em): ' + Y.Browser.document.getElementsByTagName('em'));
sys.puts('getElementByClassName(odd): ' + Y.Browser.document.getElementsByClassName('odd'));
sys.puts('');
sys.puts('Y.Browser.document.outerHTML: ');
sys.puts(Y.Browser.document.outerHTML);
});