Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Issues with dom_attach() and script_js() (r1610)
Hi all. Been playing around with these two functions all morning, modifying one of my plugins to play nicely with these functions. However, I’ve noticed a few things while doing so.
First, lines 527-529 (txplib_html.php) are missing semicolons at the end. Not terribly critical, but probably should be fixed IMO.
As well, the call to script_js() in dom_attach() (line 532) isn’t using the same parameters as the actual definition of the function. This is causing all the content to be used in the <code><noscript></code> tags as well. dom_attach() is calling js_script() with $js, $content, and $noscript, while js_script() is defined with $js, and $noscript.
Another note, not a bug / typo, but an idea – I think it would be greatly useful if dom_attach() had another parameter for an id for the wraptag, something like <code>wraptagid</code>. Then you could assign that id to the wraptag ( <code>n.setAttribute(“id”, $wraptagid);</code> ), and it would make manipulating it a lot easier.
Just my 2¢.
Last edited by akokskis (2006-08-03 16:34:13)
Offline
Re: Issues with dom_attach() and script_js() (r1610)
I put together this patch.
Offline
#3 2006-08-03 22:56:36
- zem
- Developer Emeritus

- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Issues with dom_attach() and script_js() (r1610)
First, lines 527-529 (txplib_html.php) are missing semicolons at the end. Not terribly critical, but probably should be fixed IMO.
Not sure what you mean by this. I can’t see anywhere there should (or could) be a semicolon.
[update] ah, you mean the javascript.
As well, the call to script_js() in dom_attach() (line 532) isn’t using the same parameters as the actual definition of the function.
That was already fixed in r1599, unless I’m missing something.
Thanks for the patch, looking at it now.
Last edited by zem (2006-08-03 22:59:52)
Alex
Offline
#4 2006-08-03 23:13:33
- zem
- Developer Emeritus

- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Issues with dom_attach() and script_js() (r1610)
See r1613. I simplified it a bit. Tests fine for me; are there any browsers where setAttribute('id',''); might cause a problem?
Alex
Offline
Re: Issues with dom_attach() and script_js() (r1610)
Are empty ID values valid when set through Javascript? <a href=“http://www.w3.org/TR/REC-html40/types.html#type-id”>W3C</a> says they are not in HTML4
Offline
#6 2006-08-03 23:58:19
- zem
- Developer Emeritus

- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Issues with dom_attach() and script_js() (r1610)
Can’t find anything that says either way. Neither Opera nor Firefox complain. If it aint broke.
Last edited by zem (2006-08-04 00:00:33)
Alex
Offline
#7 2006-08-04 00:56:45
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Issues with dom_attach() and script_js() (r1610)
Are empty ID values valid when set through Javascript? W3C says they are not in HTML4
It doesn’t matter, the validator doesn’t parse JavaScript. :) There isn’t anyway to unset an attribute, except to set it as empty (there is a removeAttribute function, but it doesn’t work consistently across browsers).
Offline
Re: Issues with dom_attach() and script_js() (r1610)
zem wrote:
That was already fixed in r1599, unless I’m missing something.
Ah, didn’t notice that. I’ve been running tests off code checked out of the 4.0 branch, not the crockery branch. So, it’s still messed up in the 4.0 branch.
And as far as the <code>setAttribute(‘id’,’‘);</code> being an issue, I figured it wouldn’t be, but rather be safe than sorry (to be terribly cliché).
In any event, you’re welcome for the patch. Glad that I can be of some use to this project.
Offline