Hi,
I've noticed that the hosting_site.form.js is replacing field descriptions when a field has only one valid value with the text of the only value. This is fine until a hook_form_alter is altering the field reducing it to one value only. In this specific case the current code
$desc_id.show()
.find('div.placeholder')
.contents().
replaceWith($.trim($input_id.val()));
when contents() method is call it returns an empty element. Replacing it like this example
$desc_id.show()
.find('div.placeholder')
.html($.trim($input_id.val()));
solves the problem.
Moreover contents() method (similar to children()) is used to fetch the element nodes of the given element. In this context is quite useless because we're trying to fetch nodes and then wipe them out with the replaceWith() call.
Comment | File | Size | Author |
---|---|---|---|
#1 | hostmaster-wrong_jqeury_replacement_method-1765546-2.patch | 1.38 KB | Bladedu |
Comments
Comment #1
BladeduHere's the patch that fixes the issue.
Comment #2
Steven Jones CreditAttribution: Steven Jones commentedWould it be possible to provide a reproducible test case so we can test this fix please?
I.e. does this happen with a clean install of Aegir? If not, then could you provide a minimal form alter to reproduce this issue?
Comment #3
BladeduWell I would change it anyway do to a misuses of jQuery contents() method, but you can easily reproduce the bug enabling SSL support and then implementing this in hook_form_alter for a site node form
and implement this in hook_hosting_site_options_alter()
Comment #4
Steven Jones CreditAttribution: Steven Jones commentedThanks for the information, we'll get this fix in.
Comment #5
Steven Jones CreditAttribution: Steven Jones commentedSorry, can you provide a screenshot of what you mean please? I'm struggling reproduce any issue and then apply a fix to it.
Comment #6
BladeduI'm trying to create some screenshots to show you what's happening (I have to prepare everything again to reproduce the bug).
Meanwhile you can check about contents documentation (http://api.jquery.com/contents/)
and html(value) (http://api.jquery.com/html/#html2).
Apart from the bug encountered, I think it is better to use
html()
method because it's faster than callingcontents()
(which fetch the HTML of a given selector and then builds jquery objects) and the replacing everything that has been just parsed withreplaceWith()
method.Comment #7
ergonlogicThe 1.x branch of Aegir is deprecated. Please re-open if you can re-produce this issue on the latest 2.x or later branches.