I just noticed this, I’m of the opinion that it’s a bug in Freeway’s
JavaScript engine, but I’d like to know if anyone else has a good
explanation for it before I get all huffy and file a bug.
###This doesn’t work:
var thisItem = fwDocument.fwTags.fwFind(fwItem);
var inlines = thisItem.fwFindAll(['div','img']);
for (i in inlines){
SetCSSAttribute(inlines[i],'float','left');
SetCSSAttribute(inlines[i],'vertical-align','top');
if(inline.fwFindEnclosing('p')){
var p = inlines[i].fwFindEnclosing('p');
var d = p.fwAddEnclosing('',false);
var c = p.fwFindAllContent();
d.fwMove(c);
p.fwDelete();
}
}
###This does, yet I believe they should both work
var thisItem = fwDocument.fwTags.fwFind(fwItem);
var inlines = thisItem.fwFindAll(['div','img']);
for (i in inlines){
var inline = inlines[i];
SetCSSAttribute(inline,'float','left');
SetCSSAttribute(inline,'vertical-align','top');
if(inline.fwFindEnclosing('p')){
var p = inline.fwFindEnclosing('p');
var d = p.fwAddEnclosing('',false);
var c = p.fwFindAllContent();
d.fwMove(c);
p.fwDelete();
}
}
Here is setCSSAttribute, just for reference. If I don’t use this
function, then the result is the same for both, so the problem must be
in here somewhere.
function SetCSSAttribute(tag, attributeName, attributeValue) {
// Sets a "CSS" attribute such as "position:absolute" in a tag value
// Passing an attribute value of null removes that attribute entirely
if (tag==null) return;
var tagField = tag['style'];
if (tagField == null){
tag['style'] = '"'+attributeName+':'+attributeValue+'"';
}else{
var tagField = tagField.toString();
var pairs = tagField.slice(1,-1).split(';');
var out = new Array();
if(attributeValue != null && tagField.indexOf(attributeName) < 0)
out.push(attributeName+':'+attributeValue);
for(i in pairs){
pairs[i] = pairs[i].replace(/^s*(S*(s+S+)*)s*$/, "$1");
//javascript equivalent of trim
if(pairs[i].slice(0,pairs[i].indexOf(':')) == attributeName) {
if(attributeValue != null)
out.push(attributeName+':'+attributeValue);
}else{
out.push(pairs[i]);
}
}
tag['style'] = fwQuote(out.join('; '));
}
}
Can anyone see why using the iterator directly should fail, while
assigning the iterator to a local variable works?
Walter
actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options