From 054dae2f13e2c7f92ac81afd11b5f380969d0946 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 31 Jan 2017 22:13:44 -0500 Subject: [PATCH] Restructure API based on feedback This restructures the API so that customAttributes is the default. --- README.md | 2 +- attr.js | 2 ++ global.js | 2 +- index.js | 2 +- registry.js | 2 ++ 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 692fbd4..e214595 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Add as a script tag: Or import as an ES module: ```js -import { customAttributes } from 'custom-attributes'; +import customAttributes from 'custom-attributes'; ``` Or you can just import the CustomAttributeRegistry and create your own instance: diff --git a/attr.js b/attr.js index 5c23ac7..791574d 100644 --- a/attr.js +++ b/attr.js @@ -1,6 +1,8 @@ (function () { 'use strict'; +var forEach = Array.prototype.forEach; + class CustomAttributeRegistry { constructor(ownerDocument){ if(!ownerDocument) { diff --git a/global.js b/global.js index 255de87..82cc26f 100644 --- a/global.js +++ b/global.js @@ -1,4 +1,4 @@ -import { customAttributes, CustomAttributeRegistry } from './index.js'; +import customAttributes, { CustomAttributeRegistry } from './index.js'; window.customAttributes = customAttributes; window.CustomAttributeRegistry = CustomAttributeRegistry; diff --git a/index.js b/index.js index 7ee0034..841af11 100644 --- a/index.js +++ b/index.js @@ -2,4 +2,4 @@ import CustomAttributeRegistry from './registry.js'; var customAttributes = new CustomAttributeRegistry(document); -export { customAttributes, CustomAttributeRegistry } +export { customAttributes as default, CustomAttributeRegistry } diff --git a/registry.js b/registry.js index 8789093..3fe0bf2 100644 --- a/registry.js +++ b/registry.js @@ -1,3 +1,5 @@ +var forEach = Array.prototype.forEach; + class CustomAttributeRegistry { constructor(ownerDocument){ if(!ownerDocument) {