Skip to content

Commit

Permalink
### 1.0.7
Browse files Browse the repository at this point in the history
- **Bugfixes:**
  - use indexOf instead of lastIndexOf to apply on... events
- **Enhancements:**
  - Added Polyfill for 
eplaceWith
  - Added Polyfill for 
eplaceChildren
- **Code Quality:**
  - Fixed a typo
  • Loading branch information
bfiessinger committed Jan 29, 2021
1 parent fc5057f commit 6da5e16
Show file tree
Hide file tree
Showing 44 changed files with 187 additions and 28 deletions.
6 changes: 5 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"@babel/preset-typescript"
],
[
"@babel/preset-env"
"@babel/preset-env",
{
"loose": false,
"bugfixes": true
}
]
],
"plugins": [
Expand Down
9 changes: 5 additions & 4 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# https://github.com/browserslist/browserslist#readme

> 1%
last 4 version
>= 0.5%
last 2 major versions
not dead
Chrome >= 60
Firefox >= 60
# needed since Legacy Edge still has usage; 79 was the first Chromium Edge version
# should be removed in the future when its usage drops or when it's moved to dead browsers
not Edge < 79
Firefox ESR
iOS >= 10
Safari >= 10
Android >= 6
IE >= 9
Android >= 56
not Explorer <= 10
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### 1.0.7
- **Bugfixes:**
- use `indexOf` instead of `lastIndexOf` to apply `on...` events
- **Enhancements:**
- Added Polyfill for `replaceWith`
- Added Polyfill for `replaceChildren`
- **Code Quality:**
- Fixed a typo

### 1.0.6
- **Bugfixes:**
- `replacePage()` method did not add form element classes
Expand Down
2 changes: 2 additions & 0 deletions core/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
require('./utils/polyfills');

import WizerdForm from './wizerdForm';
export default WizerdForm;
2 changes: 1 addition & 1 deletion core/utils/DOMUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function renderElement(node: wizerdFormCreateElement): Node {

// Set Attributes
for (const [k, v] of ObjEntries(node.props)) {
if ( k.lastIndexOf('on', 0) === 0 ) { // exclude attributes that should trigger events
if ( k.indexOf('on', 0) === 0 ) { // exclude attributes that should trigger events
el.addEventListener(k.slice(2).toLowerCase(), v);
} else if (el[k] !== 'undefined') {
el[k] = v;
Expand Down
27 changes: 27 additions & 0 deletions core/utils/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* ReplaceWith Polyfill
* @link https://news.ycombinator.com/item?id=17613100
*/
if (Element.prototype.replaceWith === undefined) {
Element.prototype.replaceWith = function(replacement: String | Node) {
if (typeof replacement === "string") {
replacement = this.ownerDocument.createTextNode(replacement);
}
this.parentNode.replaceChild(this, replacement);
}
}

/**
* replaceChildren Polyfill
* @link https://github.com/yuzhe-han/ParentNode-replaceChildren
*/
if((Node as any).prototype.replaceChildren === undefined) {
(Node as any).prototype.replaceChildren = function(addNodes: any) {
while(this.lastChild) {
this.removeChild(this.lastChild);
}
if (addNodes !== undefined) {
this.append(addNodes);
}
}
}
2 changes: 1 addition & 1 deletion core/wizerdForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export default class WizerdForm {
}

/**
* Add a new `WizerdFromPage` by string.
* Add a new `WizerdFormPage` by string.
* This method can be used to create pages from AJAX Calls or other
* callbacks.
*
Expand Down
1 change: 1 addition & 0 deletions dist/amd/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/amd/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/amd/utils/DOMUtils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/amd/utils/DOMUtils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added dist/amd/utils/polyfills.d.ts
Empty file.
27 changes: 27 additions & 0 deletions dist/amd/utils/polyfills.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/amd/utils/polyfills.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/amd/wizerdForm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default class WizerdForm {
*/
private prepareAddPage;
/**
* Add a new `WizerdFromPage` by string.
* Add a new `WizerdFormPage` by string.
* This method can be used to create pages from AJAX Calls or other
* callbacks.
*
Expand Down
2 changes: 1 addition & 1 deletion dist/amd/wizerdForm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/cjs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/utils/DOMUtils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/utils/DOMUtils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added dist/cjs/utils/polyfills.d.ts
Empty file.
27 changes: 27 additions & 0 deletions dist/cjs/utils/polyfills.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/cjs/utils/polyfills.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/wizerdForm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default class WizerdForm {
*/
private prepareAddPage;
/**
* Add a new `WizerdFromPage` by string.
* Add a new `WizerdFormPage` by string.
* This method can be used to create pages from AJAX Calls or other
* callbacks.
*
Expand Down
Loading

0 comments on commit 6da5e16

Please sign in to comment.