Skip to content

Commit

Permalink
bump snabbdom to v3 (#128)
Browse files Browse the repository at this point in the history
* bump snabbdom version

* update DOMPatcher due to snabbdom emptyNodeAt implmentation changes

* update examples jade loader config to be compatible with latest snabbdom

* fix formatting

* fix type import

* i dunno

* bump browser versions

* adjust package.json version to not be beta

* re-trigger ci

* pr naming nits
  • Loading branch information
RyanHirsch authored Sep 20, 2021
1 parent 1d44fce commit fb9300f
Show file tree
Hide file tree
Showing 17 changed files with 211 additions and 222 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12.22.4
2 changes: 1 addition & 1 deletion examples/animations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "[email protected]",
"license": "MIT",
"dependencies": {
"snabbdom": "^0.5.3",
"snabbdom": "3.0.3",
"@webcomponents/custom-elements": "1.0.0-rc.3"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion examples/animations/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const webpackConfig = {
root: path.join(__dirname, `node_modules`),
},
virtualJadeLoader: {
vdom: `snabbdom`,
runtime: `var h = require("snabbdom").h;`,
propsWrapper: `props`,
rawProps: true,
},
};

Expand Down
2 changes: 1 addition & 1 deletion examples/contexts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@webcomponents/custom-elements": "1.0.6",
"@webcomponents/shadydom": "1.0.8",
"snabbdom": "^0.5.3"
"snabbdom": "3.0.3"
},
"devDependencies": {
"autoprefixer-loader": "^3.2.0",
Expand Down
4 changes: 3 additions & 1 deletion examples/contexts/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const webpackConfig = {
root: path.join(__dirname, `node_modules`),
},
virtualJadeLoader: {
vdom: `snabbdom`,
runtime: `var h = require("snabbdom").h;`,
propsWrapper: `props`,
rawProps: true,
},
};

Expand Down
2 changes: 1 addition & 1 deletion examples/jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "[email protected]",
"license": "MIT",
"dependencies": {
"snabbdom-jsx-lite": "1.0.10",
"snabbdom-jsx-lite": "2.0.0",
"@webcomponents/custom-elements": "1.0.0-rc.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/shadow-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@webcomponents/custom-elements": "1.0.6",
"@webcomponents/shadydom": "1.0.8",
"snabbdom": "^0.5.3"
"snabbdom": "3.0.3"
},
"devDependencies": {
"autoprefixer-loader": "^3.2.0",
Expand Down
4 changes: 3 additions & 1 deletion examples/shadow-dom/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const webpackConfig = {
root: path.join(__dirname, `node_modules`),
},
virtualJadeLoader: {
vdom: `snabbdom`,
runtime: `var h = require("snabbdom").h;`,
propsWrapper: `props`,
rawProps: true,
},
};

Expand Down
4 changes: 2 additions & 2 deletions examples/tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"author": "[email protected]",
"license": "MIT",
"dependencies": {
"snabbdom": "^0.5.3",
"@webcomponents/custom-elements": "1.0.0-rc.3"
"@webcomponents/custom-elements": "1.0.0-rc.3",
"snabbdom": "3.0.3"
},
"devDependencies": {
"babel-core": "^6.3.17",
Expand Down
4 changes: 3 additions & 1 deletion examples/tutorial/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const webpackConfig = {
root: path.join(__dirname, `node_modules`),
},
virtualJadeLoader: {
vdom: `snabbdom`,
runtime: `var h = require("snabbdom").h;`,
propsWrapper: `props`,
rawProps: true,
},
};

Expand Down
2 changes: 1 addition & 1 deletion lib/component-utils/hook-helpers.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {VNode} from 'snabbdom/vnode';
import {VNode} from 'snabbdom';

/**
* A simple remove hook generator for snabbdom so we remove an element after it's finished its closing animation.
Expand Down
35 changes: 21 additions & 14 deletions lib/dom-patcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@
* @private
*/

import {init as initSnabbdom} from 'snabbdom';
import h from 'snabbdom/h';
import {
init as initSnabbdom,
attributesModule,
h,
datasetModule,
eventListenersModule,
propsModule,
styleModule,
classModule,
} from 'snabbdom';

import snabbAttributes from 'snabbdom/modules/attributes';
import snabbDataset from 'snabbdom/modules/dataset';
import snabbDelayedClass from 'snabbdom-delayed-class';
import snabbEventlisterners from 'snabbdom/modules/eventlisteners';
import snabbProps from 'snabbdom/modules/props';
import snabbStyle from 'snabbdom/modules/style';
import delayedClassModule from 'snabbdom-delayed-class';

const patch = initSnabbdom([
snabbAttributes,
snabbDataset,
snabbDelayedClass,
snabbEventlisterners,
snabbProps,
snabbStyle,
datasetModule,
attributesModule,
classModule,
propsModule,
styleModule,
eventListenersModule,
delayedClassModule,
]);

export const EMPTY_DIV = h(`div`);
Expand All @@ -41,6 +45,9 @@ export class DOMPatcher {
this.el = document.createElement(tagName);
if (classMatches) {
this.el.className = classMatches.map((c) => c.slice(1)).join(` `);
// this attribute setting ensures that svg elements behave as expected and will ensure
// compatibility with different snabbdom versions
this.el.setAttribute(`class`, this.el.className);
}
if (idMatch) {
this.el.id = idMatch[0].slice(1);
Expand Down
4 changes: 2 additions & 2 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Type definitions for panel
// Project: panel
// Definitions by: Mixpanel (https://mixpanel.com)
import {VNode} from 'snabbdom/vnode';
import {VNode} from 'snabbdom';
import WebComponent from 'webcomponent';

export {h} from 'snabbdom/h';
export {h} from 'snabbdom';
export {jsx} from 'snabbdom-jsx-lite';

export class StateStore<State> {
Expand Down
Loading

0 comments on commit fb9300f

Please sign in to comment.