diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-18 19:13:28 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-28 13:47:39 +0100 |
commit | b5bd292b7d042690336e08dcd423894449c36c66 (patch) | |
tree | 57e262db049c4505a32c56fd7516b087ee8d4cf3 /src | |
parent | 57d7dd0232b283874f09bb08e6d05ccfc6d1da24 (diff) | |
download | svg.js-b5bd292b7d042690336e08dcd423894449c36c66.tar.gz svg.js-b5bd292b7d042690336e08dcd423894449c36c66.zip |
add tests for all exports of adopter
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/adopter.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/utils/adopter.js b/src/utils/adopter.js index a4c60de..5c1b0b6 100644 --- a/src/utils/adopter.js +++ b/src/utils/adopter.js @@ -17,7 +17,7 @@ export function makeInstance (element) { if (element instanceof Base) return element if (typeof element === 'object') { - return adopt(element) + return adopter(element) } if (element == null) { @@ -25,7 +25,7 @@ export function makeInstance (element) { } if (typeof element === 'string' && element.charAt(0) !== '<') { - return adopt(globals.document.querySelector(element)) + return adopter(globals.document.querySelector(element)) } var node = makeNode('svg') @@ -33,7 +33,7 @@ export function makeInstance (element) { // We can use firstChild here because we know, // that the first char is < and thus an element - element = adopt(node.firstChild) + element = adopter(node.firstChild) return element } @@ -65,6 +65,12 @@ export function adopt (node) { return new elements[className](node) } +let adopter = adopt + +export function mockAdopt(mock = adopt) { + adopter = mock +} + export function register (element, name = element.name, asRoot = false) { elements[name] = element if (asRoot) elements[root] = element @@ -117,9 +123,9 @@ export function extend (modules, methods, attrCheck) { } } -export function extendWithAttrCheck (...args) { - extend(...args, true) -} +// export function extendWithAttrCheck (...args) { +// extend(...args, true) +// } export function wrapWithAttrCheck (fn) { return function (...args) { |