Hi everyone! Sorry about the delay - been busy at work.
Google did a weird thing where they added (pointless? it seems?!) ids somewhere that broke a section of my parser. I updated the module and it should work now!.
Please pull in the latest copy of FormService
from the model, or copy from this gist
If you’re interested in the diff only and don’t want to pull in the whole thing, this is what i changed (all changes in FormService
)
local labelledByPattern = "aria%-labelledby=\"(%w+)\""
changed to
local labelledByPattern = "aria%-labelledby=\"([%w%s]+)\""
meaning now it captures not just something like id="i8"
but also id="i8 i11"
…next we have
labelPattern = "id=\"" .. id .. "\".->"
local htmlTag = html:match("<(%w+) [^>]-" .. labelPattern)
labelPattern ..= "(.-)</" .. htmlTag .. ">"
changed to
labelPattern = "id=\"" .. id .. "\".->"
local htmlTag = html:match("<(%w+) [^>]-" .. labelPattern)
if htmlTag == nil then
warn("Cannot find element matching pattern " .. labelPattern)
return
end
labelPattern ..= "(.-)</" .. htmlTag .. ">"
and thennnnn
local labelledById = html:match(labelledByPattern)
assertNotNil(labelledById)
is updated to handle multiple ids. I still don’t understand why only one of these associated elements is in the DOM when i look at the form so we are operating under the assumption that only one of these associated elements is relevant or visible.
local labelledByIds = html:match(labelledByPattern)
assertNotNil(labelledByIds)
-- Recently multiple ids have been attached as labelledBy elements... which is fine
-- but its weird because some aren't even in the DOM. So, we just pick the one we find :)
local labelledById
for _, id in string.split(labelledByIds, " ") do
local text = getTextAssociatedWithId(id)
if text ~= nil then
question.inputLabel = text
labelledById = id
break
else
warn("Element not found with id " .. labelledById)
end
end
assertNotNil(labelledById)
I’m so sorry this isn’t set up with proper version control and diffs i just haven’t made the time. maybe someday As always please report any issues you are having! Appreciate the support!