@microsoft/atlas-js
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -67,2 +67,3 @@ declare class FormBehaviorElement extends HTMLElement { | ||
} | ||
declare type NavigationSteps = 'follow' | 'hash-reload' | 'replace' | 'reload' | null; | ||
export interface FormValidationError { | ||
@@ -79,5 +80,5 @@ message: string; | ||
declare type Validator = (input: HTMLValueElement, label: string) => string | null; | ||
export declare function navigateAfterSubmit(href: string, navigationStep: string | null): void; | ||
export declare function navigateAfterSubmit(href: string, navigationStep: NavigationSteps): void; | ||
export declare function collectCustomElementsByName(form: HTMLFormElement): Element[]; | ||
export {}; | ||
//# sourceMappingURL=form-behavior.d.ts.map |
@@ -396,12 +396,2 @@ import { generateElementId, kebabToCamelCase } from '../utilities/util'; | ||
a.classList.add('help', 'help-danger'); | ||
/* a.addEventListener('click', e => { | ||
console.log('e', e.target); | ||
if (isCustomElement) { | ||
const link = (e.target as HTMLAnchorElement).getAttribute('href'); | ||
if (link) { | ||
console.log('click', document.querySelector(link)); | ||
(document.querySelector(link) as HTMLElement).focus(); | ||
} | ||
} | ||
}); */ | ||
child.appendChild(a); | ||
@@ -506,2 +496,12 @@ errorList.appendChild(child); | ||
break; | ||
case 'hash-reload': | ||
if (href) { | ||
const search = href.includes('?') ? '' : window.location.search; | ||
if (href !== search + window.location.hash) { | ||
const state = (history.state || {}); | ||
window.history.pushState(state, document.title, window.location.pathname + search + href); // prevents scrolling to spot until reload | ||
} | ||
location.reload(); | ||
} | ||
break; | ||
case 'replace': | ||
@@ -508,0 +508,0 @@ if (href) { |
{ | ||
"name": "@microsoft/atlas-js", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"public": true, | ||
@@ -5,0 +5,0 @@ "description": "Scripts backing the Atlas Design System used by Microsoft's Developer Relations.", |
@@ -127,3 +127,3 @@ import { generateElementId, kebabToCamelCase } from '../utilities/util'; | ||
if (href) { | ||
navigateAfterSubmit(href, this.getAttribute('navigation')); | ||
navigateAfterSubmit(href, this.getAttribute('navigation') as NavigationSteps); | ||
} | ||
@@ -511,13 +511,2 @@ } | ||
/* a.addEventListener('click', e => { | ||
console.log('e', e.target); | ||
if (isCustomElement) { | ||
const link = (e.target as HTMLAnchorElement).getAttribute('href'); | ||
if (link) { | ||
console.log('click', document.querySelector(link)); | ||
(document.querySelector(link) as HTMLElement).focus(); | ||
} | ||
} | ||
}); */ | ||
child.appendChild(a); | ||
@@ -574,2 +563,4 @@ errorList.appendChild(child); | ||
type NavigationSteps = 'follow' | 'hash-reload' | 'replace' | 'reload' | null; | ||
export interface FormValidationError { | ||
@@ -687,3 +678,3 @@ message: string; | ||
export function navigateAfterSubmit(href: string, navigationStep: string | null) { | ||
export function navigateAfterSubmit(href: string, navigationStep: NavigationSteps) { | ||
switch (navigationStep) { | ||
@@ -698,2 +689,12 @@ case null: | ||
break; | ||
case 'hash-reload': | ||
if (href) { | ||
const search = href.includes('?') ? '' : window.location.search; | ||
if (href !== search + window.location.hash) { | ||
const state = (history.state || {}) as Record<string, any>; | ||
window.history.pushState(state, document.title, window.location.pathname + search + href); // prevents scrolling to spot until reload | ||
} | ||
location.reload(); | ||
} | ||
break; | ||
case 'replace': | ||
@@ -700,0 +701,0 @@ if (href) { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
84965
2175
1