Skip to content

Commit 1d3b37e

Browse files
authored
feat: create @ui5/webcomponents-ie11 package (#2686)
1 parent ad56eaa commit 1d3b37e

File tree

83 files changed

+536
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+536
-437
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Safari | Native
103103
Edge | Native
104104
IE 11 | With Polyfill
105105

106-
If your app needs to support **IE11** or **legacy Edge**, please follow the [instructions](https://github.com/SAP/ui5-webcomponents/blob/master/docs/Public%20Module%20Imports.md#1-old-browser-support-edge-ie11).
106+
If your app needs to support **IE11**, please follow the [instructions](https://github.com/SAP/ui5-webcomponents/blob/master/docs/Public%20Module%20Imports.md#1-old-browser-support-ie11).
107107

108108
## Project structure, development and build
109109

@@ -128,6 +128,7 @@ Project | NPM Package | Description
128128
`base` | [UI5 Web Components Base](https://www.npmjs.com/package/@ui5/webcomponents-base) | The UI5 Web Components framework itself
129129
`theme-base` | [UI5 Web Components Theme Base](https://www.npmjs.com/package/@ui5/webcomponents-theme-base) | Theming assets (the default theme and additional accessibility themes)
130130
`localization` | [UI5 Web Components Localization](https://www.npmjs.com/package/@ui5/webcomponents-localization) | `i18n` functionality and `CLDR` assets
131+
`ie11` | [UI5 Web Components IE11](https://www.npmjs.com/package/@ui5/webcomponents-ie11) | Internet Explorer 11 polyfills and adapter code
131132
`playground` | N/A | The playground application
132133

133134
### How to run the project locally:

docs/Angular-tutorial.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ If you need your application to run on Internet Explorer 11, there are some addi
136136
*Note* These steps have been tested with Angular 7. For other versions of Angular, there might be some differences.
137137

138138
1. Install all needed dependencies:
139+
140+
```bash
141+
npm install @ui5/webcomponents-ie11 --save
142+
```
143+
139144
```bash
140145
npm install --save @angular-builders/[email protected] @angular-builders/[email protected] @babel/core @babel/preset-env babel-loader
141146
```
@@ -205,7 +210,7 @@ module.exports = {
205210

206211
4. Add the following import ```to app.module.ts``` file:
207212
```js
208-
import "@ui5/webcomponents-base/dist/features/browsersupport/IE11WithWebComponentsPolyfill.js";
213+
import "@ui5/webcomponents-ie11/dist/features/IE11WithWebComponentsPolyfill.js";
209214
```
210215

211216
*Note*: The ```IE11WithWebComponentsPolyfill.js``` file includes the official webcomponents polyfill, so you don’t have to import it by yourself. (This file was released in our latest @next version. It will be shipped with our next stable release rc.6, so until then it would be available only with the @next tag)

docs/Public Module Imports.md

+5-19
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,16 @@ The `base` package provides not only the UI5 Web Components framework, but also
204204
all UI5 Web Components.
205205

206206
<a name="oldbrowsersupport"></a>
207-
### 1. Old browser support (Edge, IE11)
207+
### 1. Old browser support ( IE11)
208208

209209
Most modern browsers - **Chrome, Firefox, Safari, Edge (Chromium-based)**, support Web Components natively.
210210

211-
If your app needs to be able to run additionally on the old **Edge (EdgeHTML-based)**, you should import the following module:
211+
If your app needs to run on **IE11**, you should import:
212212

213213
```js
214-
import "@ui5/webcomponents-base/dist/features/browsersupport/Edge.js";
214+
import "@ui5/webcomponents-ie11/dist/features/IE11.js";
215215
```
216216

217-
And if your app needs to run on both **Edge** and **IE11**, you should instead import:
218-
219-
```js
220-
import "@ui5/webcomponents-base/dist/features/browsersupport/IE11.js";
221-
```
222-
(this also includes Edge support).
223-
224217
In addition, you should load the official Web Components polyfill in your index file, as described
225218
[here](https://github.com/webcomponents/polyfills/tree/master/packages/webcomponentsjs).
226219

@@ -238,22 +231,15 @@ As shown in the example above, it's recommended to load the Web Components Polyf
238231
Finally, there is an alternative to the `IE11.js` import:
239232

240233
```js
241-
import "@ui5/webcomponents-base/dist/features/browsersupport/IE11WithWebComponentsPolyfill.js";
234+
import "@ui5/webcomponents-ie11/dist/features/IE11WithWebComponentsPolyfill.js";
242235
```
243236

244237
that includes the Web Components Polyfill too, so you don't have to import it manually.
245238

246-
This may be useful in certain use cases when your app has polyfills of its own and you need to guarantee the order of exectution.
239+
This may be useful in certain use cases when your app has polyfills of its own and you need to guarantee the order of execution.
247240

248241
The three old browser support options are summarized below:
249242

250-
| |`Edge.js` | `IE11.js` | `IE11WithWebComponentsPolyfill.js` |
251-
|---|----------|-----------|------------------------------------|
252-
|Browsers supported| Edge | Edge & IE11 | Edge & IE11 |
253-
|Includes Web Components Polyfill | No* | No* | Yes|
254-
255-
`* You must include the Web Components Polyfill manually`
256-
257243
<a name="theming"></a>
258244
### 2. Theming
259245

docs/dev/Creating UI5 Web Components Packages.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ The name that you give to your package will be used by the UI5 Web Components to
2222
With `npm`:
2323
- `npm i --save @ui5/webcomponents-base @ui5/webcomponents-theme-base @ui5/webcomponents-tools`
2424
- `npm i --save-dev chromedriver`
25+
- (Optional) `npm i --save @ui5/webcomponents-ie11`
2526

2627
or with `yarn`:
2728
- `yarn add @ui5/webcomponents-base @ui5/webcomponents-theme-base @ui5/webcomponents-tools`
2829
- `yarn add -D chromedriver`
30+
- (Optional) `yarn add @ui5/webcomponents-ie11`
2931

3032
These three `@ui5/` packages will serve as foundation for your own package and web components.
3133

@@ -34,11 +36,14 @@ Package | Description
3436
`@ui5/webcomponents-base` | Base classes and Framework
3537
`@ui5/webcomponents-theme-base` | Base theming assets
3638
`@ui5/webcomponents-tools` | Build and configuration assets
39+
`@ui5/webcomponents-ie11` | (Optional) Internet Explorer 11 polyfills and adapter code
3740

3841
*Note:* `chromedriver` is a peer dependency of `@ui5/webcomponents-tools` so that you get to choose the exact version,
3942
if necessary. This is useful if, for example, you manually update Chrome on your system and you'd prefer to not have
4043
a fixed `chromedriver` version packaged with `@ui5/webcomponents-tools`.
4144

45+
*Note:* `@ui5/webcomponents-ie11` is optional and should not be installed unless you need Internet Explorer 11 support.
46+
4247
## Step 3 - run the package initialization script
4348

4449
Run the initialization script, optionally with parameters from the following table:
@@ -126,7 +131,7 @@ File | Purpose
126131
.eslintignore | Excludes the `dist/` and `test/` directories from static code scans
127132
package-scripts.js | An [nps](https://www.npmjs.com/package/nps) package scripts configuration file
128133
bundle.esm.js | Entry point for the ES6 bundle, used for development and tests. Intended for modern browsers.
129-
bundle.es5.js | Entry point for the ES5 bundle, used for development and tests. Intended for IE11 only.
134+
bundle.es5.js | Entry point for the ES5 bundle, used for development and tests. Intended for IE11 only. Delete this file if you don't need IE11 support.
130135

131136
You'll likely only need to change `bundle.esm.js` to import your new components there.
132137

package.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@
99
"ui5"
1010
],
1111
"scripts": {
12-
"build": "npm-run-all --sequential build:base build:localization build:theme-base build:icons build:icons-tnt build:main build:fiori",
12+
"build": "npm-run-all --sequential build:base build:ie11 build:localization build:theme-base build:icons build:icons-tnt build:main build:fiori",
1313
"build:localization": "cd packages/localization && yarn build",
1414
"build:base": "cd packages/base && yarn build",
15+
"build:ie11": "cd packages/ie11 && yarn build",
1516
"build:theme-base": "cd packages/theme-base && yarn build",
1617
"build:icons": "cd packages/icons && yarn build",
1718
"build:icons-tnt": "cd packages/icons-tnt && yarn build",
1819
"build:main": "cd packages/main && yarn build",
1920
"build:fiori": "cd packages/fiori && yarn build",
2021
"build:playground": "yarn build:main && yarn build:fiori && cd packages/playground && yarn build",
2122
"build:playground:master": "yarn build:main && yarn build:fiori && cd packages/playground && yarn build:master",
22-
"clean": "npm-run-all --sequential clean:base clean:localization clean:theme-base clean:icons clean:icons-tnt clean:main clean:fiori",
23+
"clean": "npm-run-all --sequential clean:base clean:ie11 clean:localization clean:theme-base clean:icons clean:icons-tnt clean:main clean:fiori",
2324
"clean:localization": "cd packages/localization && yarn clean",
2425
"clean:base": "cd packages/base && yarn clean",
26+
"clean:ie11": "cd packages/ie11 && yarn clean",
2527
"clean:theme-base": "cd packages/theme-base && yarn clean",
2628
"clean:icons": "cd packages/icons && yarn clean",
2729
"clean:icons-tnt": "cd packages/icons-tnt && yarn clean",
@@ -32,15 +34,16 @@
3234
"scopePrepare:main": "cd packages/main && nps scope.prepare",
3335
"scopePrepare:fiori": "cd packages/fiori && nps scope.prepare",
3436
"dev:base": "cd packages/base && nps watch",
37+
"dev:ie11": "cd packages/ie11 && nps watch",
3538
"dev:localization": "cd packages/localization && nps watch",
3639
"dev:main": "cd packages/main && nps dev",
3740
"dev:fiori": "cd packages/fiori && nps dev",
3841
"scopeDev:main": "cd packages/main && nps scope.dev",
3942
"scopeDev:fiori": "cd packages/fiori && nps scope.dev",
40-
"start": "npm-run-all --sequential build:base build:localization build:theme-base build:icons build:icons-tnt prepare:main prepare:fiori start:all",
41-
"startWithScope": "npm-run-all --sequential build:base build:localization build:theme-base build:icons build:icons-tnt scopePrepare:main scopePrepare:fiori scopeStart:all",
42-
"start:all": "npm-run-all --parallel dev:base dev:localization dev:main dev:fiori",
43-
"scopeStart:all": "npm-run-all --parallel dev:base dev:localization scopeDev:main scopeDev:fiori",
43+
"start": "npm-run-all --sequential build:base build:ie11 build:localization build:theme-base build:icons build:icons-tnt prepare:main prepare:fiori start:all",
44+
"startWithScope": "npm-run-all --sequential build:base build:ie11 build:localization build:theme-base build:icons build:icons-tnt scopePrepare:main scopePrepare:fiori scopeStart:all",
45+
"start:all": "npm-run-all --parallel dev:base dev:ie11 dev:localization dev:main dev:fiori",
46+
"scopeStart:all": "npm-run-all --parallel dev:base dev:ie11 dev:localization scopeDev:main scopeDev:fiori",
4447
"start:base": "cd packages/base && yarn start",
4548
"start:main": "cd packages/main && yarn start",
4649
"start:fiori": "cd packages/fiori && yarn start",
@@ -71,6 +74,7 @@
7174
"packages/fiori",
7275
"packages/icons",
7376
"packages/icons-tnt",
77+
"packages/ie11",
7478
"packages/tools",
7579
"packages/playground"
7680
]

packages/base/bundle.es5.js

-28
This file was deleted.

packages/base/bundle.esm.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { registerThemeProperties } from "./dist/AssetRegistry.js";
22

3-
// ESM bundle targets Edge + browsers with native support
4-
import "./dist/features/browsersupport/Edge.js";
3+
// ESM bundle targets browsers with native support
54
import "./dist/features/OpenUI5Support.js";
65

76
// Test components

packages/base/package-scripts.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@ const scripts = {
1212
prepare: "nps clean copy generateAssetParameters",
1313
build: {
1414
default: "nps lint prepare build.bundle",
15-
bundle: "rollup --config config/rollup.config.js --environment ES5_BUILD",
15+
bundle: "rollup --config config/rollup.config.js",
1616
},
1717
copy: {
18-
default: "nps copy.src copy.test copy.webcomponents-polyfill",
18+
default: "nps copy.src copy.test",
1919
src: "copy-and-watch \"src/**/*.js\" dist/",
2020
test: "copy-and-watch \"test/**/*.*\" dist/test-resources",
21-
"webcomponents-polyfill": "copy-and-watch \"../../node_modules/@webcomponents/webcomponentsjs/**/*.*\" dist/webcomponentsjs/",
2221
},
2322
generateAssetParameters: `node "${assetParametersScript}"`,
2423
watch: {
2524
default: 'concurrently "nps watch.test" "nps watch.src" "nps watch.bundle"',
2625
src: 'nps "copy.src --watch --skip-initial-copy"',
2726
test: 'nps "copy.test --watch --skip-initial-copy"',
28-
bundle: "rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV",
27+
bundle: "rollup --config config/rollup.config.js -w --environment DEV",
2928
},
3029
dev: 'concurrently "nps serve" "nps watch"',
3130
start: "nps prepare dev",

packages/base/package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
"prepublishOnly": "npm run clean && npm run build"
2525
},
2626
"dependencies": {
27-
"css-vars-ponyfill": "^2.1.2",
28-
"lit-html": "^1.0.0",
29-
"regenerator-runtime": "0.12.1",
30-
"url-search-params-polyfill": "^5.0.0"
27+
"lit-html": "^1.0.0"
3128
},
3229
"devDependencies": {
3330
"@ui5/webcomponents-tools": "1.0.0-rc.11",

packages/base/src/boot.js renamed to packages/base/src/Boot.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
import EventProvider from "./EventProvider.js";
12
import whenDOMReady from "./util/whenDOMReady.js";
23
import insertFontFace from "./FontFace.js";
34
import insertSystemCSSVars from "./SystemCSSVars.js";
45
import { getTheme } from "./config/Theme.js";
56
import applyTheme from "./theming/applyTheme.js";
6-
import whenPolyfillLoaded from "./compatibility/whenPolyfillLoaded.js";
77
import { getFeature } from "./FeaturesRegistry.js";
88

99
let bootPromise;
10+
const eventProvider = new EventProvider();
11+
12+
/**
13+
* Attach a callback that will be executed on boot
14+
* @public
15+
* @param listener
16+
*/
17+
const attachBoot = listener => {
18+
eventProvider.attachEvent("boot", listener);
19+
};
1020

1121
const boot = () => {
1222
if (bootPromise) {
@@ -24,11 +34,15 @@ const boot = () => {
2434
OpenUI5Support && OpenUI5Support.attachListeners();
2535
insertFontFace();
2636
insertSystemCSSVars();
27-
await whenPolyfillLoaded();
37+
await eventProvider.fireEventAsync("boot");
38+
2839
resolve();
2940
});
3041

3142
return bootPromise;
3243
};
3344

34-
export default boot;
45+
export {
46+
boot,
47+
attachBoot,
48+
};

packages/base/src/DOMObserver.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const observers = new WeakMap(); // We want just one observer per node, store them here -> DOM nodes are keys
2+
3+
/**
4+
* Default implementation with MutationObserver for browsers with native support
5+
*/
6+
let _createObserver = (node, callback, options) => {
7+
const observer = new MutationObserver(callback);
8+
observer.observe(node, options);
9+
return observer;
10+
};
11+
12+
/**
13+
* Default implementation with MutationObserver for browsers with native support
14+
*/
15+
let _destroyObserver = observer => {
16+
observer.disconnect();
17+
};
18+
19+
/**
20+
* Allows to create an alternative DOM observer implementation
21+
* @param createFn
22+
*/
23+
const setCreateObserverCallback = createFn => {
24+
_createObserver = createFn;
25+
};
26+
27+
/**
28+
* Allows to create an alternative DOM observer implementation
29+
* @param destroyFn
30+
*/
31+
const setDestroyObserverCallback = destroyFn => {
32+
_destroyObserver = destroyFn;
33+
};
34+
35+
/**
36+
* @param node
37+
* @param callback
38+
* @param options
39+
*/
40+
const observeDOMNode = (node, callback, options) => {
41+
const observer = _createObserver(node, callback, options);
42+
observers.set(node, observer);
43+
};
44+
45+
/**
46+
* @param node
47+
*/
48+
const unobserveDOMNode = node => {
49+
const observer = observers.get(node);
50+
if (observer) {
51+
_destroyObserver(observer);
52+
observers.delete(node);
53+
}
54+
};
55+
56+
export {
57+
setCreateObserverCallback,
58+
setDestroyObserverCallback,
59+
observeDOMNode,
60+
unobserveDOMNode,
61+
};

packages/base/src/EventProvider.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class EventProvider {
3636

3737
/**
3838
* Fires an event and returns the results of all event listeners as an array.
39-
* Example: If listeners return promises, you can: await fireEvent("myEvent") to know when all listeners have finished.
4039
*
4140
* @param eventName the event to fire
4241
* @param data optional data to pass to each event listener
@@ -55,6 +54,17 @@ class EventProvider {
5554
});
5655
}
5756

57+
/**
58+
* Fires an event and returns a promise that will resolve once all listeners have resolved.
59+
*
60+
* @param eventName the event to fire
61+
* @param data optional data to pass to each event listener
62+
* @returns {Promise} a promise that will resolve when all listeners have resolved
63+
*/
64+
fireEventAsync(eventName, data) {
65+
return Promise.all(this.fireEvent(eventName, data));
66+
}
67+
5868
isHandlerAttached(eventName, fnFunction) {
5969
const eventRegistry = this._eventRegistry;
6070
const eventListeners = eventRegistry[eventName];

0 commit comments

Comments
 (0)