@ideal-postcodes/address-finder
Advanced tools
Comparing version 2.4.2 to 2.5.0
@@ -0,1 +1,8 @@ | ||
# [2.5.0](https://github.com/ideal-postcodes/address-finder/compare/2.4.2...2.5.0) (2021-10-15) | ||
### Features | ||
* **Watch:** Allow custom load identifiers ([9ea9a44](https://github.com/ideal-postcodes/address-finder/commit/9ea9a44784b33636dc4b5a4f927308fbad19ac76)) | ||
## [2.4.2](https://github.com/ideal-postcodes/address-finder/compare/2.4.1...2.4.2) (2021-10-06) | ||
@@ -2,0 +9,0 @@ |
@@ -77,2 +77,7 @@ import { Controller } from "./controller"; | ||
immediate?: boolean; | ||
/** | ||
* Configure marker for solution is attached to specific context/anchor | ||
* in DOM | ||
*/ | ||
marker?: string; | ||
} | ||
@@ -79,0 +84,0 @@ export interface BindResult { |
@@ -9,3 +9,3 @@ "use strict"; | ||
const isTrue = () => true; | ||
const getAnchors = (config) => { | ||
const getAnchors = (config, marker) => { | ||
const scope = jsutil_1.getScope(config.scope || null); | ||
@@ -15,3 +15,3 @@ const matches = scope.querySelectorAll(config.anchor || | ||
(config.outputFields || {}).line_1); | ||
return jsutil_1.toArray(matches).filter((e) => !jsutil_1.loaded(e)); | ||
return jsutil_1.toArray(matches).filter((e) => !jsutil_1.loaded(e, marker)); | ||
}; | ||
@@ -38,6 +38,6 @@ const DEFAULT_INTERVAL = 1000; | ||
return null; | ||
const { getScope = formScope, interval = DEFAULT_INTERVAL, anchor, onBind = controller_1.NOOP, onAnchorFound = controller_1.NOOP, onBindAttempt = controller_1.NOOP, immediate = true, } = options; | ||
const { getScope = formScope, interval = DEFAULT_INTERVAL, anchor, onBind = controller_1.NOOP, onAnchorFound = controller_1.NOOP, onBindAttempt = controller_1.NOOP, immediate = true, marker = "idpc", } = options; | ||
const bind = () => { | ||
onBindAttempt({ config, options }); | ||
getAnchors({ anchor, ...config }).forEach((anchor) => { | ||
getAnchors({ anchor, ...config }, marker).forEach((anchor) => { | ||
const scope = getScope(anchor); | ||
@@ -49,3 +49,3 @@ if (!scope) | ||
const c = index_1.setup(newConfig); | ||
jsutil_1.markLoaded(anchor); | ||
jsutil_1.markLoaded(anchor, marker); | ||
onBind(c); | ||
@@ -52,0 +52,0 @@ }); |
@@ -77,2 +77,7 @@ import { Controller } from "./controller"; | ||
immediate?: boolean; | ||
/** | ||
* Configure marker for solution is attached to specific context/anchor | ||
* in DOM | ||
*/ | ||
marker?: string; | ||
} | ||
@@ -79,0 +84,0 @@ export interface BindResult { |
@@ -6,3 +6,3 @@ import { Client, checkKeyUsability } from "@ideal-postcodes/core-axios"; | ||
const isTrue = () => true; | ||
const getAnchors = (config) => { | ||
const getAnchors = (config, marker) => { | ||
const scope = getScope(config.scope || null); | ||
@@ -12,3 +12,3 @@ const matches = scope.querySelectorAll(config.anchor || | ||
(config.outputFields || {}).line_1); | ||
return toArray(matches).filter((e) => !loaded(e)); | ||
return toArray(matches).filter((e) => !loaded(e, marker)); | ||
}; | ||
@@ -35,6 +35,6 @@ const DEFAULT_INTERVAL = 1000; | ||
return null; | ||
const { getScope = formScope, interval = DEFAULT_INTERVAL, anchor, onBind = NOOP, onAnchorFound = NOOP, onBindAttempt = NOOP, immediate = true, } = options; | ||
const { getScope = formScope, interval = DEFAULT_INTERVAL, anchor, onBind = NOOP, onAnchorFound = NOOP, onBindAttempt = NOOP, immediate = true, marker = "idpc", } = options; | ||
const bind = () => { | ||
onBindAttempt({ config, options }); | ||
getAnchors({ anchor, ...config }).forEach((anchor) => { | ||
getAnchors({ anchor, ...config }, marker).forEach((anchor) => { | ||
const scope = getScope(anchor); | ||
@@ -46,3 +46,3 @@ if (!scope) | ||
const c = setup(newConfig); | ||
markLoaded(anchor); | ||
markLoaded(anchor, marker); | ||
onBind(c); | ||
@@ -49,0 +49,0 @@ }); |
{ | ||
"name": "@ideal-postcodes/address-finder", | ||
"version": "2.4.2", | ||
"version": "2.5.0", | ||
"description": "Address Finder JS library backed by the Ideal Postcodes UK address search API", | ||
@@ -101,3 +101,3 @@ "main": "dist/index.js", | ||
"@ideal-postcodes/core-axios": "~3.0.5", | ||
"@ideal-postcodes/jsutil": "~4.6.0", | ||
"@ideal-postcodes/jsutil": "~4.6.1", | ||
"@xstate/fsm": "~1.6.0", | ||
@@ -104,0 +104,0 @@ "lodash": "~4.17.20" |
180350
4736