Short attributes in tags

Hi,
one of my more funky Actions puts a tag in the header, and references an external .js file. Looking at what’s available to this in XHTML and HTML 5, there are some additional attributes that can be added to the tag - async and defer.

However, there are differences between XHTML and HTML 5. In XHTML, the attributes must have a value, so you need (and this is to shop both attributes in play - this may not be necessary):

<script src="javascript.js" type="text/javascript" async="async" defer="defer"></script>

In HTML5, you would type:

<script src="javascript.js" type="text/javascript" async defer></script>

You will notice that you just need the attribute name, NOT the values. I can’t see how to do this in an Action.

So, Action code looks a little like this right now:

 var head = fwDocument.fwTags.fwFind("head",fwPage);
 var myScript = myTag.fwAddOpt("script",true);
 myScript["src"] = fwQuote("javscript.js");
 myScript["type"] = fwQuote("text/javascript");
 myScript["async"]=fwQuote("async");
 myScript["defer"]=fwQuote("defer");

That last line is good for XHTML 5, but how would you just drop in the attribute name without the value. For reasons that are necessary (and good and proper), I obviously want the action to put the tag into the tag tree as it is currently doing, so it’s available for other actions to manipulate (if necessary - and at this it is necessary).


actionsdev mailing list
email@hidden
Update your subscriptions at:

I don’t think you can do the single-value tags in the usual Action tag manipulation method. You could easily convert the tag to text and write it into the output stream with the additional attributes, but then it would not be a tag, and further manipulation by other Actions would be impossible.

It’s important to note that HTML5 allows the single-ended attributes, but does not require them. Almost everything about HTML5 is more lenient than XHTML, but the formal XML-like syntax is valid, too. Try validating a page that uses the “loose” syntax and then the same page with the async=“async” style using the W3C validator.

Walter

On Mar 5, 2019, at 4:12 AM, Paul email@hidden wrote:

Hi,
one of my more funky Actions puts a

In HTML5, you would type:

You will notice that you just need the attribute name, NOT the values. I can’t see how to do this in an Action.

So, Action code looks a little like this right now:

var head = fwDocument.fwTags.fwFind("head",fwPage);
var myScript = myTag.fwAddOpt("script",true);
myScript["src"] = fwQuote("javscript.js");
myScript["type"] = fwQuote("text/javascript");
myScript["async"]=fwQuote("async");
myScript["defer"]=fwQuote("defer");

That last line is good for XHTML 5, but how would you just drop in the attribute name without the value. For reasons that are necessary (and good and proper), I obviously want the action to put the tag into the tag tree as it is currently doing, so it’s available for other actions to manipulate (if necessary - and at this it is necessary).


actionsdev mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


actionsdev mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Thanks, Walter. I’ll keep the Action as it is for the moment.

On 5 Mar 2019, 2:09 pm, waltd wrote:

I don’t think you can do the single-value tags in the usual Action tag manipulation method. You could easily convert the tag to text and write it into the output stream with the additional attributes, but then it would not be a tag, and further manipulation by other Actions would be impossible.

It’s important to note that HTML5 allows the single-ended attributes, but does not require them. Almost everything about HTML5 is more lenient than XHTML, but the formal XML-like syntax is valid, too. Try validating a page that uses the “loose” syntax and then the same page with the async=“async” style using the W3C validator.

Walter

On Mar 5, 2019, at 4:12 AM, Paul


actionsdev mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Hi Paul,

I saw this thread earlier today and knew I’d faced this same problem before but just couldn’t locate the Action I was thinking about.

After a bit of testing it appears the solution is to pass an empty string into your attributes;

function fwAfterEndHTML(){
	var head = fwDocument.fwTags.fwFind("head",fwPage);
	var myScript = head.fwAddOpt("script",true);	
	
	myScript["src"] = fwQuote("javscript.js");
	myScript["type"] = fwQuote("text/javascript");
	
	myScript["async"] = "";
	myScript["defer"] = "";
}

which gives you;

<script src="javscript.js" type="text/javascript" async defer></script>

I had thought that setting the fwTitle or fwValue on the attribute to null would do the job.


actionsdev mailing list
email@hidden
Update your subscriptions at:

Ah, thanks., Tim!


actionsdev mailing list
email@hidden
Update your subscriptions at: