Saturday, 21. January 2006, 15:45:02
Live DOM Viewer
Converted it into user js:LiveDomViewer.js
Invoked with CTRL+ALT+double_click
Just the DOM Viewer part. Tag names are clickable to reveal computed style properties.
Thanks to Ian Hickson and aleto.
Screenshot: LiveDOM.png
Tuesday, 24. January 2006, 04:15:08
Thursday, 26. January 2006, 23:03:15 (edited)
Originally posted by xErath:
a advice - to export the least symbols as possible and therefore not pollute the global window namespace and prevent collisions, declare all function before the dblclick listener, and wrap the entire script with (function(){ ...code here... })();. Also, declare ALL variables as local.
I've tried to fix it, but one function can not be made local as it's executed when user clicks tag name.
And is there a way in javascript to explicitly declare local variable? How to do it (prepend it with var)? [edit: It seems so when I'm testing this now
Originally posted by Stoen:
The script fails for non standard tags as seen in the hide-objects UserJS. The attributes collection for non standard tag seems to be undefined. Probably something that should be changed in that script though...
Getting computed styles for such elements is failing, but the DOM tree shows them (with attributes) here without problems. Or you are talking about something else?
I've updated the script. Now it also shows tag properties and methods in popup window (once again, I borrowed code from someone but I don't remember who
LiveDomViewer.js
Friday, 27. January 2006, 00:23:36 (edited)
Originally posted by d.i.z.:
Getting computed styles for such elements is failing, but the DOM tree shows them (with attributes) here without problems. Or you are talking about something else?
The script fails on this line
if (node.childNodes[[b][/b]i].attributes[j].specified) { Its not the whole collection that is undefined, it says the length of the attributes collection for the custom element as found in hide-objects is 1. But attributes[0] is undefined and the script then fails at the above line.Edit: Any custom element with a style attribute will result in the same thing. Otherwise custom elements work as you described
Friday, 27. January 2006, 00:47:49
Originally posted by Stoen:
Originally posted by d.i.z.:
Getting computed styles for such elements is failing, but the DOM tree shows them (with attributes) here without problems. Or you are talking about something else?
The script fails on this lineif (node.childNodes[[b][/b]i].attributes[j].specified) {Its not the whole collection that is undefined, it says the length of the attributes collection for the custom element as found in hide-objects is 1. But attributes[0] is undefined and the script then fails at the above line.
Edit: Any custom element with a style attribute will result in the same thing. Otherwise custom elements work as you described
I see now. Quick fix could look like this:
if (node.childNodes[i].attributes[j] && node.childNodes[i].attributes[j].specified) {
although this is dirty fix as it will skip some attributes. I'm not really into this problem but it looks like it may be an Opera bug. Or maybe it's because we try to use custom tags in HTML which (I guess) is illegal?
Sunday, 29. January 2006, 17:26:51 (edited)
Now it shows computed styles inline (which can get painfully slow because of 'overflow: auto' btw.
Oh, and whole script is in one anonymous function (it was possible it seems
Can someone tell me, which method is generally faster - innerHTML or DOM compliant element creation?
It's here and in first post:
LiveDomViewer.js
Thursday, 2. February 2006, 07:16:14
Originally posted by d.i.z.:
DOM compliant element creation of course, but you'll have to work over a document fragment otherwise doing dom tree operation will force re-flows which can drastically slow down the code.Can someone tell me, which method is generally faster - innerHTML or DOM compliant element creation?
Thursday, 2. February 2006, 15:05:05
http://verens.com/archives/2006/01/09/clonenode-caching/
Saturday, 4. February 2006, 04:54:50
Originally posted by d.i.z.:
I did my own testing, but unlike quirksmode testing which creates the html and renders it, my script continuously appended pieces of HTML to the dom tree, becoming slower and slower as the html grew, while dom methods always spent the same amount of time.Some say that innerHTML is faster
Forums » Opera Community » General Opera topics » User JavaScript