Skip to content

Commit eadbe2c

Browse files
committed
0.3.3
* Adding clostest polyfill for IE 9+ * Fixing some README issues * Bumping a few dependencies * Properyly utilizing HTMLWebpackPlugin * Adding .yalc to .gitignore
1 parent 88dff9d commit eadbe2c

10 files changed

Lines changed: 48 additions & 23 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ module.exports = {
1313
rules: {
1414
'@typescript-eslint/explicit-function-return-type': 0,
1515
'@typescript-eslint/ban-ts-ignore': 'warn',
16+
'@typescript-eslint/no-this-alias': 'warn',
1617
},
1718
};

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ typings/
6363
# build artifacts
6464
pkg/
6565
playground/dist/
66+
.yalc/
67+
yalc.lock

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import React from 'react';
6161
import ReactDOM from 'react-dom';
6262

6363
import { Shuttle, useShuttleState } from 'react-accessible-shuttle';
64+
import 'react-accessible-shuttle/css/shuttle.css';
6465

6566
function App() {
6667
const shuttle = useShuttleState({
@@ -176,7 +177,7 @@ You can also use react-accessible-shuttle via CDN -- it even works with legacy b
176177
]);
177178
}
178179
179-
ReactDOM.render(App, document.getElementById('root'));
180+
ReactDOM.render(React.createElement(App), document.getElementById('root'));
180181
</script>
181182
</body>
182183
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"test": "jest --silent",
1010
"build": "npm run clean && npm run lint && npm run build:css && pika build && npm run clean:css",
11-
"build:css": "sass -s compressed --embed-source-map src/styles/** ./css/shuttle.css",
11+
"build:css": "sass -s compressed --no-charset --embed-sources src/styles/** ./css/shuttle.css",
1212
"build:test": "npm run clean && tsc src/index.ts --pretty --jsx react --esModuleInterop --downLevelIteration --outDir pkg",
1313
"clean": "rimraf pkg/",
1414
"clean:css": "rimraf css/",

playground/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
"node-sass": "^4.12.0",
2525
"postcss-loader": "^3.0.0",
2626
"react-hot-loader": "^4.12.12",
27-
"sass-loader": "^7.3.1",
27+
"sass-loader": "^8.0.0",
2828
"style-loader": "^1.0.0",
2929
"ts-loader": "^6.0.4",
3030
"webpack": "^4.39.3",
31-
"webpack-cli": "^3.3.7",
31+
"webpack-cli": "^3.3.8",
3232
"webpack-dev-server": "^3.8.0"
3333
},
3434
"dependencies": {

playground/public/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
</head>
6+
<body>
7+
<div id="root"></div>
8+
</body>
9+
</html>

playground/src/index.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ import { App as SearchShuttle } from './examples/with-search';
1111

1212
import '../../src/styles/shuttle.scss';
1313

14-
if (process.env.NODE_ENV === 'development') {
15-
(function() {
16-
const div = document.createElement('div');
17-
div.id = 'root';
18-
19-
document.body.appendChild(div);
20-
})();
21-
}
22-
2314
function Main() {
2415
return (
2516
<main>

playground/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ module.exports = {
1515
filename: '[name].css',
1616
chunkFilename: '[id].css',
1717
}),
18-
new HtmlWebpackPlugin(),
18+
new HtmlWebpackPlugin({
19+
template: path.resolve('./public/index.html'),
20+
}),
1921
],
2022
resolve: {
2123
extensions: ['.tsx', '.ts', '.js'],

src/utils/utils.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,22 @@ export const isContainer = (container: HTMLDivElement) => {
165165

166166
return bool && (name === SHUTTLE_CONTAINERS.SOURCE || name === SHUTTLE_CONTAINERS.TARGET);
167167
};
168+
169+
// IE 9+ polyfill for closest
170+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
171+
if (!Element.prototype.closest) {
172+
Element.prototype.closest = function(selector: string) {
173+
// @ts-ignore
174+
let el: any = this;
175+
176+
do {
177+
if (el.matches(selector)) {
178+
return el;
179+
}
180+
181+
el = el.parentElement || el.parentNode;
182+
} while (el !== null && el.nodeType === 1);
183+
184+
return null;
185+
};
186+
}

0 commit comments

Comments
 (0)