From c58edfdb64f1646321b4f832bef855fac853d827 Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Tue, 6 Feb 2018 11:54:21 +0000
Subject: [PATCH] Wrap and unwrap the select field with a special div

---
 addressfield/static/address_form.js | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/addressfield/static/address_form.js b/addressfield/static/address_form.js
index 5bfdccb82..8681d445e 100644
--- a/addressfield/static/address_form.js
+++ b/addressfield/static/address_form.js
@@ -55,6 +55,24 @@
         oldValidate.call(this, field, config);
     };
 
+    var selectWrap = '<div class="form__select"></div>';
+
+    // Hook into the select builder to update the display
+    var oldConvertToSelect = $.fn.addressfield.convertToSelect;
+    $.fn.addressfield.convertToSelect = function() {
+        var $select = oldConvertToSelect.call(this);
+        $select.wrap(selectWrap);
+        return $select;
+    };
+
+    // Hook into the text builder to update the display
+    var oldConvertToText = $.fn.addressfield.convertToText;
+    $.fn.addressfield.convertToText = function() {
+        var $text = oldConvertToText.call(this);
+        $text.unwrap(selectWrap);
+        return $text;
+    };
+
     $(document).ready(function formReady() {
         $('.form div.address').addressfield({
             json: '/static/addressfield.min.json',
-- 
GitLab