From 16dfe603ff5fd7a070261c6dd9a9009ceaff7dd1 Mon Sep 17 00:00:00 2001 From: Jenny Schweers Date: Tue, 1 Oct 2024 11:13:47 -0400 Subject: [PATCH] Updated regex for make_data_attribute_renames --- .../apps/hqwebapp/tests/utils/test_bootstrap_changes.py | 9 +++++++++ corehq/apps/hqwebapp/utils/bootstrap/changes.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/corehq/apps/hqwebapp/tests/utils/test_bootstrap_changes.py b/corehq/apps/hqwebapp/tests/utils/test_bootstrap_changes.py index 51f4f2404d2a..0d1b84ced6cc 100644 --- a/corehq/apps/hqwebapp/tests/utils/test_bootstrap_changes.py +++ b/corehq/apps/hqwebapp/tests/utils/test_bootstrap_changes.py @@ -79,6 +79,15 @@ def test_make_data_attribute_renames_bootstrap5(): eq(renames, ['renamed data-toggle to data-bs-toggle']) +def test_ko_make_data_attribute_renames_bootstrap5(): + line = """ data-bind="attr: {'data-target': '#modalGroup-' + id()}"\n""" + final_line, renames = make_data_attribute_renames( + line, get_spec('bootstrap_3_to_5') + ) + eq(final_line, """ data-bind="attr: {'data-bs-target': '#modalGroup-' + id()}"\n""") + eq(renames, ['renamed data-target to data-bs-target']) + + def test_make_javascript_dependency_renames(): line = """ "hqwebapp/js/bootstrap3/widgets",\n""" final_line, renames = make_javascript_dependency_renames( diff --git a/corehq/apps/hqwebapp/utils/bootstrap/changes.py b/corehq/apps/hqwebapp/utils/bootstrap/changes.py index ccb1684e0103..1d3be701b196 100644 --- a/corehq/apps/hqwebapp/utils/bootstrap/changes.py +++ b/corehq/apps/hqwebapp/utils/bootstrap/changes.py @@ -127,7 +127,7 @@ def make_data_attribute_renames(line, spec): return _do_rename( line, spec['data_attribute_renames'], - lambda x: r"([\n }])(" + x + r")(=[\"\'])", + lambda x: r"([\n }\"\'])(" + x + r")([\"\']?[=:]\s*[\"\'])", lambda x: r"\1" + spec['data_attribute_renames'][x] + r"\3" )