Currently, the main API is createImgTag() generating a complete img element, containing the image data in the src attribute as base64 encoded string. Setting other attributes (like id, class or style) or applying an style to that element is a bit cumbersome (not impossible, but additional work), because the HTML element isn't there before the call.
Other QR code libraries often have an additional method which generates just the data string (which createImgTag() creates as well, by the way), which then can be set / applied to an existing img element with other attributes remaining present.
So, suggestion is to refactor some of the logic of createImgTag() into createDataURL() which latter method can also be called separately. Idea:
Currently, the main API is
createImgTag()
generating a completeimg
element, containing the image data in thesrc
attribute as base64 encoded string. Setting other attributes (likeid
,class
orstyle
) or applying an style to that element is a bit cumbersome (not impossible, but additional work), because the HTML element isn't there before the call.Other QR code libraries often have an additional method which generates just the data string (which
createImgTag()
creates as well, by the way), which then can be set / applied to an existingimg
element with other attributes remaining present.So, suggestion is to refactor some of the logic of
createImgTag()
intocreateDataURL()
which latter method can also be called separately. Idea: