@hyperspan/framework 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js
CHANGED
|
@@ -279,7 +279,7 @@ var tryDecode = (str, decoder) => {
|
|
|
279
279
|
var tryDecodeURI = (str) => tryDecode(str, decodeURI);
|
|
280
280
|
var getPath = (request) => {
|
|
281
281
|
const url = request.url;
|
|
282
|
-
const start = url.indexOf("/", url.
|
|
282
|
+
const start = url.indexOf("/", url.indexOf(":") + 4);
|
|
283
283
|
let i = start;
|
|
284
284
|
for (;i < url.length; i++) {
|
|
285
285
|
const charCode = url.charCodeAt(i);
|
package/package.json
CHANGED
|
@@ -110,8 +110,13 @@ window.customElements.define('hs-action', HSAction);
|
|
|
110
110
|
const actionFormObserver = new MutationObserver((list) => {
|
|
111
111
|
list.forEach((mutation) => {
|
|
112
112
|
mutation.addedNodes.forEach((node) => {
|
|
113
|
-
if (node instanceof HTMLFormElement) {
|
|
114
|
-
bindHSActionForm(
|
|
113
|
+
if (node && ('closest' in node || node instanceof HTMLFormElement)) {
|
|
114
|
+
bindHSActionForm(
|
|
115
|
+
(node as HTMLElement).closest('hs-action') as HSAction,
|
|
116
|
+
node instanceof HTMLFormElement
|
|
117
|
+
? node
|
|
118
|
+
: ((node as HTMLElement | HTMLFormElement).querySelector('form') as HTMLFormElement)
|
|
119
|
+
);
|
|
115
120
|
}
|
|
116
121
|
});
|
|
117
122
|
});
|
|
@@ -127,6 +132,7 @@ function bindHSActionForm(hsActionElement: HSAction, form: HTMLFormElement) {
|
|
|
127
132
|
|
|
128
133
|
form.setAttribute('action', hsActionElement.getAttribute('url') || '');
|
|
129
134
|
const submitHandler = (e: Event) => {
|
|
135
|
+
e.preventDefault();
|
|
130
136
|
formSubmitToRoute(e, form as HTMLFormElement, {
|
|
131
137
|
afterResponse: () => bindHSActionForm(hsActionElement, form),
|
|
132
138
|
});
|
|
@@ -140,10 +146,8 @@ function bindHSActionForm(hsActionElement: HSAction, form: HTMLFormElement) {
|
|
|
140
146
|
*/
|
|
141
147
|
type TFormSubmitOptons = { afterResponse: () => any };
|
|
142
148
|
function formSubmitToRoute(e: Event, form: HTMLFormElement, opts: TFormSubmitOptons) {
|
|
143
|
-
e.preventDefault();
|
|
144
|
-
|
|
145
|
-
const formUrl = form.getAttribute('action') || '';
|
|
146
149
|
const formData = new FormData(form);
|
|
150
|
+
const formUrl = form.getAttribute('action') || '';
|
|
147
151
|
const method = form.getAttribute('method')?.toUpperCase() || 'POST';
|
|
148
152
|
const headers = {
|
|
149
153
|
Accept: 'text/html',
|