A review of some common pitfalls and how to avoid or discover them. Includes a quick overview of some of the debugging tools available (as of late 2009). Generic web dev content as well as YUI-specific content.
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Debugging tips in YUI 3
1. Debugging in YUI 3
Luke Smith
yuilibrary: lsmith
github: lsmith
twitter: @ls_n
YUICONF 2009
Tuesday, January 18, 2011
2. “Debugging is all about
challenging your own
assumptions. At least one of
them was obviously wrong.”
-- some bald guy
YUICONF 2009
Tuesday, January 18, 2011
4. This is what we're up against
YUICONF 2009
Tuesday, January 18, 2011
5. This is what we're up against
HTML
Tag soup
Quirks mode
Unsupported tags
YUICONF 2009
Tuesday, January 18, 2011
6. This is what we're up against
HTML CSS
Tag soup Cascade/Specificity
Quirks mode Stacking context
Unsupported tags Box model
YUICONF 2009
Tuesday, January 18, 2011
7. This is what we're up against
HTML CSS JavaScript
Tag soup Cascade/Specificity Function scoping
Quirks mode Stacking context Late binding
Unsupported tags Box model this
YUICONF 2009
Tuesday, January 18, 2011
8. This is what we're up against
HTML CSS JavaScript
Tag soup Cascade/Specificity Function scoping
Quirks mode Stacking context Late binding
Unsupported tags Box model this
DOM
Reflows
Event system
Asynchronicity
YUICONF 2009
Tuesday, January 18, 2011
9. This is what we're up against
HTML CSS JavaScript
Tag soup Cascade/Specificity Function scoping
Quirks mode Stacking context Late binding
Unsupported tags Box model this
DOM Browser
Reflows Implementations
Event system Security policy
Asynchronicity Bugs
YUICONF 2009
Tuesday, January 18, 2011
10. This is what we're up against
HTML CSS JavaScript
Tag soup Cascade/Specificity Function scoping
Quirks mode Stacking context Late binding
Unsupported tags Box model this
DOM Browser Library
Reflows Implementations Inconsistent API
Event system Security policy Version nuances
Asynchronicity Bugs Bugs
YUICONF 2009
Tuesday, January 18, 2011
12. The actual problem
(understand the problem space)
YUICONF 2009
Tuesday, January 18, 2011
13. It’s the nature of a library to
change the playing field
CSS
Required HTML
knowledge
DOM Browser
JS
YUICONF 2009
Tuesday, January 18, 2011
14. It’s the nature of a library to
change the playing field
Required Browser Library
knowledge CSS
HTML
DOM
JS
YUICONF 2009
Tuesday, January 18, 2011
15. We try
Consistent API Much improved
Interoperability Still great
Documentation Good, but can improve
Bugs Where?!
YUICONF 2009
Tuesday, January 18, 2011
16. What we have to work with
YUICONF 2009
Tuesday, January 18, 2011
17. What we have to work with
‣ Inspectors
YUICONF 2009
Tuesday, January 18, 2011
18. What we have to work with
‣ Inspectors
‣ Console
YUICONF 2009
Tuesday, January 18, 2011
19. What we have to work with
‣ Inspectors
‣ Console
‣ Debuggers
YUICONF 2009
Tuesday, January 18, 2011
20. What we have to work with
‣ Inspectors
‣ Console
‣ Debuggers
‣ Community
YUICONF 2009
Tuesday, January 18, 2011
21. What we have to work with
‣ Inspectors
‣ Console
‣ Debuggers
‣ Community
YUICONF 2009
Tuesday, January 18, 2011
22. Inspector
YUICONF 2009
Tuesday, January 18, 2011
23. Console
YUICONF 2009
Tuesday, January 18, 2011
24. Console
YUICONF 2009
Tuesday, January 18, 2011
25. Debugger
YUICONF 2009
Tuesday, January 18, 2011
26. Debugger
YUICONF 2009
Tuesday, January 18, 2011
27. Debugger
YUICONF 2009
Tuesday, January 18, 2011
28. Debugger
YUICONF 2009
Tuesday, January 18, 2011
29. Debugger
YUICONF 2009
Tuesday, January 18, 2011
30. Debugger
YUICONF 2009
Tuesday, January 18, 2011
31. FireBug
YUICONF 2009
Tuesday, January 18, 2011
32. FireBug
YUICONF 2009
Tuesday, January 18, 2011
33. FireBug
YUICONF 2009
Tuesday, January 18, 2011
34. FireBug
YUICONF 2009
Tuesday, January 18, 2011
35. FireBug
YUICONF 2009
Tuesday, January 18, 2011
36. FireBug
YUICONF 2009
Tuesday, January 18, 2011
37. Web Inspector
YUICONF 2009
Tuesday, January 18, 2011
38. Web Inspector
YUICONF 2009
Tuesday, January 18, 2011
39. Web Inspector
YUICONF 2009
Tuesday, January 18, 2011
40. Web Inspector
YUICONF 2009
Tuesday, January 18, 2011
41. Dragonfly
YUICONF 2009
Tuesday, January 18, 2011
42. Dragonfly
YUICONF 2009
Tuesday, January 18, 2011
43. Dragonfly
YUICONF 2009
Tuesday, January 18, 2011
44. Dragonfly
YUICONF 2009
Tuesday, January 18, 2011
54. Developer tools
Firefox
Safari
Opera
IE8
IE7
IE6
YUICONF 2009
Tuesday, January 18, 2011
55. Developer tools
Firefox ➡ FireBug
Safari ➡ Web Inspector
Opera ➡ Dragonfly
IE8 ➡ Developer Tools
IE7 ➡ MS Vis. Web Dev + Dev Toolbar
IE6 ➡ MS Vis. Web Dev + Dev Toolbar
YUICONF 2009
Tuesday, January 18, 2011
58. Inspector
Problem: "[something] isn't showing up"
Step 1: Verify it's in the DOM
YUICONF 2009
Tuesday, January 18, 2011
59. Inspector
Problem: "[something] isn't showing up"
Step 1: Verify it's in the DOM
Step 2: Hover the element for highlight
YUICONF 2009
Tuesday, January 18, 2011
60. Inspector
Problem: "[something] isn't showing up"
Step 1: Verify it's in the DOM
Step 2: Hover the element for highlight
Step 3: Check for missing/overridden styles
YUICONF 2009
Tuesday, January 18, 2011
61. Inspector
Problem: "[something] isn't showing up"
Step 1: Verify it's in the DOM
Step 2: Hover the element for highlight
Step 3: Check for missing/overridden styles
Step 4: Check the CSS of its ancestors
YUICONF 2009
Tuesday, January 18, 2011
62. Inspector
Problem: "[something] isn't showing up"
Step 1: Verify it's in the DOM
Step 2: Hover the element for highlight
Step 3: Check for missing/overridden styles
Step 4: Check the CSS of its ancestors
Step 5: Disable styles, position, zoom
YUICONF 2009
Tuesday, January 18, 2011
63. Inspector
Problem: "[something] isn't showing up"
Step 1: Verify it's in the DOM
Step 2: Hover the element for highlight
Step 3: Check for missing/overridden styles
Step 4: Check the CSS of its ancestors
Step 5: Disable styles, position, zoom
Step 6: Reduce
YUICONF 2009
Tuesday, January 18, 2011
92. Problem: "Where's my data?"
var data;
Y.io(url, {
on: {
success: function (id, o) {
data = o.responseText;
}
}
});
displayData(data);
YUICONF 2009
Tuesday, January 18, 2011
93. "Where's my data?"
var data;
Y.io(url, {
on: {
success: function (id, o) {
data = o.responseText;
}
}
});
displayData(data);
YUICONF 2009
Tuesday, January 18, 2011
94. "Where's my data?"
var data; 1
2
Y.io(url, {
on: { 4
success: function (id, o) {
data = o.responseText;
}
}
});
3
displayData(data);
YUICONF 2009
Tuesday, January 18, 2011
97. "Where's my data?"
‣ Expectation = breakpoint
‣ Console or Net for XHR inspection
YUICONF 2009
Tuesday, January 18, 2011
98. Problem: "X is not a function"
YUI(config).use('io-base', function (Y) {
function displayData(stuff) {
content = stuff || "BOOM";
Y.one('#x').setContent( content );
}
var data;
Y.io(url,{ on:{success: callback} });
displayData(data);
YUICONF 2009
Tuesday, January 18, 2011
99. "X is not a function"
"Object does not support this
property or method"
"TypeError: Result of expression
'Y.one' [undefined] is not a
function."
YUICONF 2009
Tuesday, January 18, 2011
100. "X is not a function"
YUICONF 2009
Tuesday, January 18, 2011
101. "X is not a function"
‣ Break on all errors
YUICONF 2009
Tuesday, January 18, 2011
102. "X is not a function"
‣ Break on all errors
‣ Documentation
YUICONF 2009
Tuesday, January 18, 2011
103. "X is not a function"
‣ Break on all errors
‣ Documentation
‣ Dependency Configurator
YUICONF 2009
Tuesday, January 18, 2011
104. "X is not a function"
FireBug
Web Inspector
YUICONF 2009
Tuesday, January 18, 2011
105. Problem: "Selector not working?"
YUI(config).use('node', function (Y) {
Y.one('div:contains(YUI)')
.addClass("where-u-at");
YUICONF 2009
Tuesday, January 18, 2011
106. Problem: "Selector not working?"
YUI(config).use('node', function (Y) {
Y.one('div:contains(YUI)')
.addClass("where-u-at");
selector-css3
YUICONF 2009
Tuesday, January 18, 2011
125. "X is not a function"
and
Missing module
‣ Break on all errors
‣ Expectation = breakpoint
‣ Documentation
‣ Community
YUICONF 2009
Tuesday, January 18, 2011
126. Problem: "Can't access Y"
YUI(config).use('node', function (Y) {
/* implementation */
});
// Y is not visible here
YUICONF 2009
Tuesday, January 18, 2011
133. Problem: "Can't access Y"
var Y = YUI().use('node', function (Y) {
/* implementation */
});
// Y IS visible here
YUICONF 2009
Tuesday, January 18, 2011
134. Problem: "I want the DOM node"
var node = Y.one("#myform .button");
var nodeList = Y.all("#myform .button");
YUICONF 2009
Tuesday, January 18, 2011
135. Problem: "I want the DOM node"
domNode = node._node;
domNodes = nodeList._nodes;
Y.Node.getDOMNode( node );
Y.NodeList.getDOMNodes( nodeList );
YUICONF 2009
Tuesday, January 18, 2011
136. Community
ydn-javascript
yui3
yuilibrary.com/forum
stackoverflow.com
#yui
YUICONF 2009
Tuesday, January 18, 2011
137. Community
"Help us help you"
ydn-javascript
yui3
yuilibrary.com/forum
stackoverflow.com
#yui
YUICONF 2009
Tuesday, January 18, 2011
138. Community
‣ Check the Forum archives
‣ Reduce
‣ gist
YUICONF 2009
Tuesday, January 18, 2011