Skip to content

Commit

Permalink
Polyfill Object.assign with extends helper
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Jan 31, 2020
1 parent 82ef6f6 commit d7ec692
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 27 deletions.
18 changes: 9 additions & 9 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"dist/react-beautiful-dnd.js": {
"bundled": 365555,
"minified": 134065,
"gzipped": 39834
"bundled": 365453,
"minified": 134037,
"gzipped": 39824
},
"dist/react-beautiful-dnd.min.js": {
"bundled": 307334,
"minified": 109550,
"gzipped": 31958
"bundled": 307232,
"minified": 109522,
"gzipped": 31948
},
"dist/react-beautiful-dnd.esm.js": {
"bundled": 241599,
"minified": 125790,
"gzipped": 32910,
"bundled": 241497,
"minified": 125757,
"gzipped": 32899,
"treeshaked": {
"rollup": {
"code": 21158,
Expand Down
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
presets: ['@babel/react', '@babel/flow', ['@babel/env', { loose: true }]],
plugins: [
'@babel/transform-object-assign',
['@babel/proposal-class-properties', { loose: true }],
// used for stripping out the `invariant` messages in production builds
'dev-expression',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
"@babel/plugin-transform-object-assign": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-env": "^7.6.3",
"@babel/preset-flow": "^7.0.0",
Expand Down
16 changes: 0 additions & 16 deletions src/view/assign-visually-hidden-style.js

This file was deleted.

5 changes: 3 additions & 2 deletions src/view/use-announcer/use-announcer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useMemo, useCallback } from 'use-memo-one';
import type { Announce, ContextId } from '../../types';
import { warning } from '../../dev-warning';
import getBodyElement from '../get-body-element';
import assignVisuallyHidden from '../assign-visually-hidden-style';
import visuallyHidden from '../visually-hidden-style';

export const getId = (contextId: ContextId): string =>
`rbd-announcement-${contextId}`;
Expand All @@ -31,7 +31,8 @@ export default function useAnnouncer(contextId: ContextId): Announce {
el.setAttribute('aria-atomic', 'true');

// hide the element visually
assignVisuallyHidden(el.style);
// eslint-disable-next-line es5/no-es6-static-methods
Object.assign(el.style, visuallyHidden);

// Add to body
getBodyElement().appendChild(el);
Expand Down
16 changes: 16 additions & 0 deletions src/view/visually-hidden-style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @flow
// https://allyjs.io/tutorials/hiding-elements.html
// Element is visually hidden but is readable by screen readers
const visuallyHidden: Object = {
position: 'absolute',
width: '1px',
height: '1px',
margin: '-1px',
border: '0',
padding: '0',
overflow: 'hidden',
clip: 'rect(0 0 0 0)',
'clip-path': 'inset(100%)',
};

export default visuallyHidden;
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250"
integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==

"@babel/helper-plugin-utils@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.8.3.tgz#9ea293be19babc0f52ff8ca88b34c3611b208670"
integrity sha512-j+fq49Xds2smCUNYmEHF9kGNkhbet6yVIBp4e6oeQpH1RUs/Ir06xUKzDjDkGcaaokPiTNs2JBWHjaE4csUkZQ==

"@babel/helper-regex@^7.0.0", "@babel/helper-regex@^7.4.4":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.5.5.tgz#0aa6824f7100a2e0e89c1527c23936c152cab351"
Expand Down Expand Up @@ -633,6 +638,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-transform-object-assign@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.8.3.tgz#dc3b8dd50ef03837868a37b7df791f64f288538e"
integrity sha512-i3LuN8tPDqUCRFu3dkzF2r1Nx0jp4scxtm7JxtIqI9he9Vk20YD+/zshdzR9JLsoBMlJlNR82a62vQExNEVx/Q==
dependencies:
"@babel/helper-plugin-utils" "^7.8.3"

"@babel/plugin-transform-object-super@^7.5.5":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.5.5.tgz#c70021df834073c65eb613b8679cc4a381d1a9f9"
Expand Down

0 comments on commit d7ec692

Please sign in to comment.