fix(qrcode): calculate margins using real size instead of DOM offset

Replaces the dependency on `offsetWidth` and `offsetHeight` with a deterministic calculation based on module count and cell size. This prevents incorrect (huge) margins when the QR code is generated inside a hidden container where offset dimensions are 0.

Fixes: Margin values calculation in QRCode drawing logic.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-10 04:27:16 +00:00
1 parent fc25801811
commit e4e07ad7e8
1 file changed
+2 -2
+2 -2
View File
@@ -364,8 +364,8 @@ if (hasDocument) {
// Fix the margin values as real size.
var elTable = _el.childNodes[0];
var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2;
var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2;
var nLeftMarginTable = (_htOption.width - (nCount * nWidth)) / 2;
var nTopMarginTable = (_htOption.height - (nCount * nHeight)) / 2;
if (nLeftMarginTable > 0 && nTopMarginTable > 0) {
updateQrCodeContainerStyles(_el, {