Skip to content

Commit 763a8cf

Browse files
tanner-reitsrwaskiewicz
authored andcommitted
chore(compiler): remove safari10 extras flag (#4421)
* remove safari10 extras flag * remove `safari10` references in some tests * add field removal to breaking changes
1 parent 4044852 commit 763a8cf

17 files changed

+16
-73
lines changed

BREAKING_CHANGES.md

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ the [dynamic `import()`
2525
function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import)
2626
for use at runtime. For Stencil v4.0.0 this field and corresponding behavior has been removed.
2727

28+
##### `__deprecated__safari10`
29+
30+
If `extras.__deprecated__safari10` is set to `true` the Stencil runtime will patch ES module
31+
support for Safari 10. In Stencil v4.0.0 this field and corresponding behavior has been removed.
32+
2833
## Stencil v3.0.0
2934

3035
* [General](#general)

src/app-data/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ export const BUILD: BuildConditionals = {
6363
cloneNodeFix: false,
6464
hydratedAttribute: false,
6565
hydratedClass: true,
66-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
67-
safari10: false,
6866
scriptDataOpts: false,
6967
scopedSlotTextContentFix: false,
7068
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field

src/client/client-patch-browser.ts

+9-33
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,20 @@ export const patchBrowser = (): Promise<d.CustomElementsDefineOptions> => {
3434
}
3535

3636
// @ts-ignore
37-
const scriptElm =
38-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
39-
BUILD.scriptDataOpts || BUILD.safari10
40-
? Array.from(doc.querySelectorAll('script')).find(
41-
(s) =>
42-
new RegExp(`\/${NAMESPACE}(\\.esm)?\\.js($|\\?|#)`).test(s.src) ||
43-
s.getAttribute('data-stencil-namespace') === NAMESPACE
44-
)
45-
: null;
37+
const scriptElm = BUILD.scriptDataOpts
38+
? Array.from(doc.querySelectorAll('script')).find(
39+
(s) =>
40+
new RegExp(`\/${NAMESPACE}(\\.esm)?\\.js($|\\?|#)`).test(s.src) ||
41+
s.getAttribute('data-stencil-namespace') === NAMESPACE
42+
)
43+
: null;
4644
const importMeta = import.meta.url;
4745
const opts = BUILD.scriptDataOpts ? ((scriptElm as any) || {})['data-opts'] || {} : {};
4846

49-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
50-
if (BUILD.safari10 && 'onbeforeload' in scriptElm && !history.scrollRestoration /* IS_ESM_BUILD */) {
51-
// Safari < v11 support: This IF is true if it's Safari below v11.
52-
// This fn cannot use async/await since Safari didn't support it until v11,
53-
// however, Safari 10 did support modules. Safari 10 also didn't support "nomodule",
54-
// so both the ESM file and nomodule file would get downloaded. Only Safari
55-
// has 'onbeforeload' in the script, and "history.scrollRestoration" was added
56-
// to Safari in v11. Return a noop then() so the async/await ESM code doesn't continue.
57-
// IS_ESM_BUILD is replaced at build time so this check doesn't happen in systemjs builds.
58-
return {
59-
then() {
60-
/* promise noop */
61-
},
62-
} as any;
63-
}
64-
65-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
66-
if (!BUILD.safari10 && importMeta !== '') {
47+
if (importMeta !== '') {
6748
opts.resourcesUrl = new URL('.', importMeta).href;
68-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
69-
} else if (BUILD.safari10) {
70-
opts.resourcesUrl = new URL(
71-
'.',
72-
new URL(scriptElm.getAttribute('data-resources-url') || scriptElm.src, win.location.href)
73-
).href;
7449
}
50+
7551
return promiseResolve(opts);
7652
};
7753

src/compiler/app-core/app-data.ts

-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ export const updateBuildConditionals = (config: Config, b: BuildConditionals) =>
150150
b.slotChildNodesFix = config.extras.slotChildNodesFix;
151151
b.cloneNodeFix = config.extras.cloneNodeFix;
152152
b.lifecycleDOMEvents = !!(b.isDebug || config._isTesting || config.extras.lifecycleDOMEvents);
153-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
154-
b.safari10 = config.extras.__deprecated__safari10;
155153
b.scopedSlotTextContentFix = !!config.extras.scopedSlotTextContentFix;
156154
b.scriptDataOpts = config.extras.scriptDataOpts;
157155
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field

src/compiler/config/test/validate-config.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,6 @@ describe('validation', () => {
390390
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
391391
expect(config.extras.__deprecated__cssVarsShim).toBe(false);
392392
expect(config.extras.lifecycleDOMEvents).toBe(false);
393-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
394-
expect(config.extras.__deprecated__safari10).toBe(false);
395393
expect(config.extras.scriptDataOpts).toBe(false);
396394
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
397395
expect(config.extras.__deprecated__shadowDomShim).toBe(false);

src/compiler/config/validate-config.ts

-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ export const validateConfig = (
108108
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
109109
validatedConfig.extras.__deprecated__cssVarsShim = !!validatedConfig.extras.__deprecated__cssVarsShim;
110110
validatedConfig.extras.lifecycleDOMEvents = !!validatedConfig.extras.lifecycleDOMEvents;
111-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
112-
validatedConfig.extras.__deprecated__safari10 = !!validatedConfig.extras.__deprecated__safari10;
113111
validatedConfig.extras.scriptDataOpts = !!validatedConfig.extras.scriptDataOpts;
114112
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
115113
validatedConfig.extras.__deprecated__shadowDomShim = !!validatedConfig.extras.__deprecated__shadowDomShim;

src/compiler/optimize/optimize-js.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ export const optimizeJs = async (inputOpts: OptimizeJsInput) => {
1313

1414
try {
1515
const prettyOutput = !!inputOpts.pretty;
16-
const config: Config = {
17-
extras: {
18-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
19-
__deprecated__safari10: true,
20-
},
21-
};
16+
const config: Config = {};
2217
const sourceTarget = inputOpts.target === 'es5' ? 'es5' : 'latest';
2318
const minifyOpts = getTerserOptions(config, sourceTarget, prettyOutput);
2419

src/compiler/optimize/optimize-module.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ export const optimizeModule = async (
128128
export const getTerserOptions = (config: Config, sourceTarget: SourceTarget, prettyOutput: boolean): MinifyOptions => {
129129
const opts: MinifyOptions = {
130130
ie8: false,
131-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
132-
safari10: !!config.extras.__deprecated__safari10,
131+
safari10: false,
133132
format: {},
134133
sourceMap: config.sourceMap,
135134
};

src/compiler/output-targets/dist-hydrate-script/generate-hydrate-app.ts

-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ const getHydrateBuildConditionals = (config: d.ValidatedConfig, cmps: d.Componen
137137
build.cloneNodeFix = false;
138138
build.appendChildSlotFix = false;
139139
build.slotChildNodesFix = false;
140-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
141-
build.safari10 = false;
142140
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
143141
build.shadowDomShim = false;
144142

src/compiler/output-targets/dist-hydrate-script/hydrate-build-conditionals.ts

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export const getHydrateBuildConditionals = (cmps: d.ComponentCompilerMeta[]) =>
2727
build.cssAnnotations = true;
2828
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
2929
build.shadowDomShim = true;
30-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
31-
build.safari10 = false;
3230
build.hydratedAttribute = false;
3331
build.hydratedClass = true;
3432
build.scriptDataOpts = false;

src/declarations/stencil-private.ts

-2
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ export interface BuildConditionals extends Partial<BuildFeatures> {
180180
hydratedAttribute?: boolean;
181181
hydratedClass?: boolean;
182182
initializeNextTick?: boolean;
183-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
184-
safari10?: boolean;
185183
scriptDataOpts?: boolean;
186184
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
187185
shadowDomShim?: boolean;

src/declarations/stencil-public-compiler.ts

-11
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,6 @@ export interface ConfigExtras {
316316
*/
317317
lifecycleDOMEvents?: boolean;
318318

319-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
320-
/**
321-
* Safari 10 supports ES modules with `<script type="module">`, however, it did not implement
322-
* `<script nomodule>`. When set to `true`, the runtime will patch support for Safari 10
323-
* due to its lack of `nomodule` support.
324-
* Defaults to `false`.
325-
*
326-
* @deprecated Since Stencil v3.0.0, Safari 10 is no longer supported.
327-
*/
328-
__deprecated__safari10?: boolean;
329-
330319
/**
331320
* It is possible to assign data to the actual `<script>` element's `data-opts` property,
332321
* which then gets passed to Stencil's initial bootstrap. This feature is only required

src/testing/reset-build-conditionals.ts

-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ export function resetBuildConditionals(b: d.BuildConditionals) {
4949
b.appendChildSlotFix = false;
5050
b.cloneNodeFix = false;
5151
b.hotModuleReplacement = false;
52-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
53-
b.safari10 = false;
5452
b.scriptDataOpts = false;
5553
b.scopedSlotTextContentFix = false;
5654
b.slotChildNodesFix = false;

src/testing/spec-page.ts

-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ export async function newSpecPage(opts: NewSpecPageOptions): Promise<SpecPage> {
135135
BUILD.cloneNodeFix = false;
136136
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
137137
BUILD.shadowDomShim = false;
138-
// TODO(STENCIL-663): Remove code related to deprecated `safari10` field.
139-
BUILD.safari10 = false;
140138
BUILD.attachStyles = !!opts.attachStyles;
141139

142140
if (typeof opts.url === 'string') {

test/jest-spec-runner/stencil.config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export const config: Config = {
1010
hydratedFlag: null,
1111
extras: {
1212
cssVarsShim: false,
13-
safari10: false,
1413
scriptDataOpts: false,
1514
shadowDomShim: false,
1615
},

test/karma/stencil.config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export const config: Config = {
3333
cloneNodeFix: true,
3434
cssVarsShim: true,
3535
lifecycleDOMEvents: true,
36-
safari10: true,
3736
scopedSlotTextContentFix: true,
3837
scriptDataOpts: true,
3938
shadowDomShim: true,

test/todo-app/stencil.config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export const config: Config = {
1212
hydratedFlag: null,
1313
extras: {
1414
cssVarsShim: false,
15-
safari10: false,
1615
scriptDataOpts: false,
1716
shadowDomShim: false,
1817
},

0 commit comments

Comments
 (0)