@startinblox/core 0.17.31 → 0.18.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_snowpack/pkg/autolinker.js +3515 -3367
- package/dist/_snowpack/pkg/autolinker.js.map +1 -1
- package/dist/_snowpack/pkg/common/{_baseUnary-217dffb2.js → _baseUnary-c1edb653.js} +16 -40
- package/dist/_snowpack/pkg/common/{_baseUnary-217dffb2.js.map → _baseUnary-c1edb653.js.map} +1 -1
- package/dist/_snowpack/pkg/common/{_commonjsHelpers-8c19dec8.js → _commonjsHelpers-37fa8da4.js} +6 -2
- package/dist/_snowpack/pkg/common/_commonjsHelpers-37fa8da4.js.map +1 -0
- package/dist/_snowpack/pkg/common/{decode-a4c334cf.js → decode-26fbf385.js} +38 -69
- package/dist/_snowpack/pkg/common/decode-26fbf385.js.map +1 -0
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js +1104 -0
- package/dist/_snowpack/pkg/common/lit-html-3647afce.js.map +1 -0
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js +4767 -4246
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +1 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js +107 -139
- package/dist/_snowpack/pkg/dialog-polyfill.js.map +1 -1
- package/dist/_snowpack/pkg/fusejs.js +411 -601
- package/dist/_snowpack/pkg/fusejs.js.map +1 -1
- package/dist/_snowpack/pkg/jsonld-context-parser.js +718 -686
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map +1 -1
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +59 -59
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +1 -1
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +14 -14
- package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +1 -1
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +13 -14
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +1 -1
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +17 -15
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +1 -1
- package/dist/_snowpack/pkg/lit-html/directives/until.js +45 -46
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map +1 -1
- package/dist/_snowpack/pkg/lit-html.js +37 -35
- package/dist/_snowpack/pkg/lit-html.js.map +1 -1
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js +1 -20
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map +1 -1
- package/dist/_snowpack/pkg/markdown-it.js +1731 -2284
- package/dist/_snowpack/pkg/markdown-it.js.map +1 -1
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js +236 -294
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +1 -1
- package/dist/_snowpack/pkg/quill.js +12077 -11017
- package/dist/_snowpack/pkg/quill.js.map +1 -1
- package/dist/_snowpack/pkg/slim-select.js +711 -1
- package/dist/_snowpack/pkg/slim-select.js.map +1 -1
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +1 -16
- package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +1 -1
- package/dist/_snowpack/pkg/tui-calendar.js +44297 -40075
- package/dist/_snowpack/pkg/tui-calendar.js.map +1 -1
- package/dist/components/solid-ac-checker.js +4 -17
- package/dist/components/solid-calendar.js +5 -26
- package/dist/components/solid-delete.js +9 -24
- package/dist/components/solid-display.js +15 -59
- package/dist/components/solid-form-search.js +27 -79
- package/dist/components/solid-form.js +48 -143
- package/dist/components/solid-lang.js +8 -19
- package/dist/components/solid-map.js +26 -64
- package/dist/components/solid-table.js +51 -133
- package/dist/components/solid-widget.js +2 -24
- package/dist/index.js +17 -11
- package/dist/libs/Component.js +4 -10
- package/dist/libs/ComponentFactory.js +6 -34
- package/dist/libs/Compositor.js +8 -15
- package/dist/libs/Sib.js +7 -21
- package/dist/libs/filter.js +184 -0
- package/dist/libs/helpers.js +19 -47
- package/dist/libs/interfaces.js +1 -1
- package/dist/libs/lit-helpers.js +7 -34
- package/dist/libs/polyfills.js +7 -10
- package/dist/libs/store/server-pagination.js +22 -0
- package/dist/libs/store/server-search.js +35 -0
- package/dist/libs/store/store.js +212 -227
- package/dist/mixins/attributeBinderMixin.js +17 -25
- package/dist/mixins/contextMixin.js +5 -7
- package/dist/mixins/counterMixin.js +2 -23
- package/dist/mixins/federationMixin.js +2 -14
- package/dist/mixins/filterMixin.js +60 -100
- package/dist/mixins/grouperMixin.js +11 -18
- package/dist/mixins/highlighterMixin.js +2 -8
- package/dist/mixins/interfaces.js +3 -5
- package/dist/mixins/listMixin.js +12 -43
- package/dist/mixins/nextMixin.js +1 -4
- package/dist/mixins/paginateMixin.js +17 -30
- package/dist/mixins/requiredMixin.js +1 -9
- package/dist/mixins/serverPaginationMixin.js +122 -0
- package/dist/mixins/sorterMixin.js +26 -44
- package/dist/mixins/storeMixin.js +28 -21
- package/dist/mixins/translationMixin.js +2 -12
- package/dist/mixins/validationMixin.js +28 -46
- package/dist/mixins/widgetMixin.js +58 -154
- package/dist/new-widgets/attributeMixins/actionMixin.js +1 -2
- package/dist/new-widgets/attributeMixins/blankMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/booleanMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/index.js +1 -2
- package/dist/new-widgets/attributeMixins/mailtoMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/multipleMixin.js +1 -2
- package/dist/new-widgets/attributeMixins/numberMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/placeholderMixin.js +1 -4
- package/dist/new-widgets/attributeMixins/telMixin.js +1 -4
- package/dist/new-widgets/baseWidgetMixin.js +5 -18
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js +3 -11
- package/dist/new-widgets/callbackMixins/index.js +1 -2
- package/dist/new-widgets/callbackMixins/richtextMixin.js +1 -6
- package/dist/new-widgets/interfaces.js +1 -0
- package/dist/new-widgets/new-widget-factory.js +14 -19
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js +6 -21
- package/dist/new-widgets/templateAdditionMixins/index.js +2 -3
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +5 -18
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js +5 -18
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js +21 -27
- package/dist/new-widgets/templates/displayTemplatesDirectory.js +35 -70
- package/dist/new-widgets/templates/formTemplatesDirectory.js +350 -315
- package/dist/new-widgets/templates/groupTemplatesDirectory.js +5 -15
- package/dist/new-widgets/templates/index.js +1 -2
- package/dist/new-widgets/templates/setTemplatesDirectory.js +4 -37
- package/dist/new-widgets/templatesDependencies/altMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/editableMixin.js +9 -26
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +3 -7
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +1 -5
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +1 -11
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +3 -13
- package/dist/new-widgets/templatesDependencies/formFileMixin.js +1 -13
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/formMixin.js +4 -14
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js +1 -5
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js +1 -5
- package/dist/new-widgets/templatesDependencies/formStepMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/linkTextMixin.js +13 -0
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +23 -18
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +1 -10
- package/dist/new-widgets/templatesDependencies/patternMixin.js +1 -2
- package/dist/new-widgets/templatesDependencies/rangeMixin.js +5 -15
- package/dist/new-widgets/templatesDependencies/setMixin.js +1 -4
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +1 -4
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +1 -5
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js +5 -11
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +1 -5
- package/dist/new-widgets/valueTransformationMixins/index.js +1 -2
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +1 -7
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +1 -5
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +1 -7
- package/dist/solid-template-element.js +24 -44
- package/dist/widgets/baseWidget.js +21 -85
- package/dist/widgets/widget-factory.js +4 -6
- package/package.json +8 -6
- package/dist/_snowpack/env.js +0 -3
- package/dist/_snowpack/pkg/autolinker.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map +0 -1
- package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map +0 -1
- package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/common/lit-html-babd44cd.js +0 -1119
- package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map +0 -1
- package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/dialog-polyfill.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/fusejs.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/jsonld-context-parser.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/markdown-it-link-attributes.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/quill.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +0 -1
- package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +0 -1
- package/dist/components/solid-ac-checker.js.map +0 -1
- package/dist/components/solid-calendar.js.map +0 -1
- package/dist/components/solid-delete.js.map +0 -1
- package/dist/components/solid-display.js.map +0 -1
- package/dist/components/solid-form-search.js.map +0 -1
- package/dist/components/solid-form.js.map +0 -1
- package/dist/components/solid-lang.js.map +0 -1
- package/dist/components/solid-map.js.map +0 -1
- package/dist/components/solid-table.js.map +0 -1
- package/dist/components/solid-widget.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/libs/Component.js.map +0 -1
- package/dist/libs/ComponentFactory.js.map +0 -1
- package/dist/libs/Compositor.js.map +0 -1
- package/dist/libs/Sib.js.map +0 -1
- package/dist/libs/helpers.js.map +0 -1
- package/dist/libs/interfaces.js.map +0 -1
- package/dist/libs/lit-helpers.js.map +0 -1
- package/dist/libs/polyfills.js.map +0 -1
- package/dist/libs/store/store.js.map +0 -1
- package/dist/mixins/attributeBinderMixin.js.map +0 -1
- package/dist/mixins/contextMixin.js.map +0 -1
- package/dist/mixins/counterMixin.js.map +0 -1
- package/dist/mixins/federationMixin.js.map +0 -1
- package/dist/mixins/filterMixin.js.map +0 -1
- package/dist/mixins/grouperMixin.js.map +0 -1
- package/dist/mixins/highlighterMixin.js.map +0 -1
- package/dist/mixins/interfaces.js.map +0 -1
- package/dist/mixins/listMixin.js.map +0 -1
- package/dist/mixins/nextMixin.js.map +0 -1
- package/dist/mixins/paginateMixin.js.map +0 -1
- package/dist/mixins/requiredMixin.js.map +0 -1
- package/dist/mixins/sorterMixin.js.map +0 -1
- package/dist/mixins/storeMixin.js.map +0 -1
- package/dist/mixins/translationMixin.js.map +0 -1
- package/dist/mixins/validationMixin.js.map +0 -1
- package/dist/mixins/widgetMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/actionMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/blankMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/booleanMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/index.js.map +0 -1
- package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/multipleMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/numberMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +0 -1
- package/dist/new-widgets/attributeMixins/telMixin.js.map +0 -1
- package/dist/new-widgets/baseWidgetMixin.js.map +0 -1
- package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +0 -1
- package/dist/new-widgets/callbackMixins/index.js.map +0 -1
- package/dist/new-widgets/callbackMixins/richtextMixin.js.map +0 -1
- package/dist/new-widgets/new-widget-factory.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/index.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +0 -1
- package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +0 -1
- package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/formTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templates/index.js.map +0 -1
- package/dist/new-widgets/templates/setTemplatesDirectory.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/altMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/editableMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/patternMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/setMixin.js.map +0 -1
- package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/index.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +0 -1
- package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +0 -1
- package/dist/solid-template-element.js.map +0 -1
- package/dist/widgets/baseWidget.js.map +0 -1
- package/dist/widgets/widget-factory.js.map +0 -1
|
@@ -33,19 +33,10 @@ function safeDispatchEvent(target, event) {
|
|
|
33
33
|
function createsStackingContext(el) {
|
|
34
34
|
while (el && el !== document.body) {
|
|
35
35
|
var s = window.getComputedStyle(el);
|
|
36
|
-
var invalid = function(k, ok) {
|
|
36
|
+
var invalid = function (k, ok) {
|
|
37
37
|
return !(s[k] === undefined || s[k] === ok);
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
if (s.opacity < 1 ||
|
|
41
|
-
invalid('zIndex', 'auto') ||
|
|
42
|
-
invalid('transform', 'none') ||
|
|
43
|
-
invalid('mixBlendMode', 'normal') ||
|
|
44
|
-
invalid('filter', 'none') ||
|
|
45
|
-
invalid('perspective', 'none') ||
|
|
46
|
-
s['isolation'] === 'isolate' ||
|
|
47
|
-
s.position === 'fixed' ||
|
|
48
|
-
s.webkitOverflowScrolling === 'touch') {
|
|
39
|
+
if (s.opacity < 1 || invalid('zIndex', 'auto') || invalid('transform', 'none') || invalid('mixBlendMode', 'normal') || invalid('filter', 'none') || invalid('perspective', 'none') || s['isolation'] === 'isolate' || s.position === 'fixed' || s.webkitOverflowScrolling === 'touch') {
|
|
49
40
|
return true;
|
|
50
41
|
}
|
|
51
42
|
el = el.parentElement;
|
|
@@ -62,7 +53,8 @@ function createsStackingContext(el) {
|
|
|
62
53
|
function findNearestDialog(el) {
|
|
63
54
|
while (el) {
|
|
64
55
|
if (el.localName === 'dialog') {
|
|
65
|
-
return /** @type {HTMLDialogElement} */
|
|
56
|
+
return (/** @type {HTMLDialogElement} */el
|
|
57
|
+
);
|
|
66
58
|
}
|
|
67
59
|
if (el.parentElement) {
|
|
68
60
|
el = el.parentElement;
|
|
@@ -87,7 +79,6 @@ function safeBlur(el) {
|
|
|
87
79
|
while (el && el.shadowRoot && el.shadowRoot.activeElement) {
|
|
88
80
|
el = el.shadowRoot.activeElement;
|
|
89
81
|
}
|
|
90
|
-
|
|
91
82
|
if (el && el.blur && el !== document.body) {
|
|
92
83
|
el.blur();
|
|
93
84
|
}
|
|
@@ -126,13 +117,12 @@ function findFocusableElementWithin(hostElement) {
|
|
|
126
117
|
// Note that this is 'any focusable area'. This list is probably not exhaustive, but the
|
|
127
118
|
// alternative involves stepping through and trying to focus everything.
|
|
128
119
|
var opts = ['button', 'input', 'keygen', 'select', 'textarea'];
|
|
129
|
-
var query = opts.map(function(el) {
|
|
120
|
+
var query = opts.map(function (el) {
|
|
130
121
|
return el + ':not([disabled])';
|
|
131
122
|
});
|
|
132
123
|
// TODO(samthor): tabindex values that are not numeric are not focusable.
|
|
133
|
-
query.push('[tabindex]:not([disabled]):not([tabindex=""])');
|
|
124
|
+
query.push('[tabindex]:not([disabled]):not([tabindex=""])'); // tabindex != "", not disabled
|
|
134
125
|
var target = hostElement.querySelector(query.join(', '));
|
|
135
|
-
|
|
136
126
|
if (!target && 'attachShadow' in Element.prototype) {
|
|
137
127
|
// If we haven't found a focusable target, see if the host element contains an element
|
|
138
128
|
// which has a shadowRoot.
|
|
@@ -167,19 +157,16 @@ function findFormSubmitter(event) {
|
|
|
167
157
|
if (event.submitter) {
|
|
168
158
|
return event.submitter;
|
|
169
159
|
}
|
|
170
|
-
|
|
171
160
|
var form = event.target;
|
|
172
161
|
if (!(form instanceof HTMLFormElement)) {
|
|
173
162
|
return null;
|
|
174
163
|
}
|
|
175
|
-
|
|
176
164
|
var submitter = dialogPolyfill.formSubmitter;
|
|
177
165
|
if (!submitter) {
|
|
178
166
|
var target = event.target;
|
|
179
|
-
var root =
|
|
167
|
+
var root = 'getRootNode' in target && target.getRootNode() || document;
|
|
180
168
|
submitter = root.activeElement;
|
|
181
169
|
}
|
|
182
|
-
|
|
183
170
|
if (!submitter || submitter.form !== form) {
|
|
184
171
|
return null;
|
|
185
172
|
}
|
|
@@ -193,7 +180,7 @@ function maybeHandleSubmit(event) {
|
|
|
193
180
|
if (event.defaultPrevented) {
|
|
194
181
|
return;
|
|
195
182
|
}
|
|
196
|
-
var form = /** @type {!HTMLFormElement} */
|
|
183
|
+
var form = /** @type {!HTMLFormElement} */event.target;
|
|
197
184
|
|
|
198
185
|
// We'd have a value if we clicked on an imagemap.
|
|
199
186
|
var value = dialogPolyfill.imagemapUseValue;
|
|
@@ -215,7 +202,6 @@ function maybeHandleSubmit(event) {
|
|
|
215
202
|
return;
|
|
216
203
|
}
|
|
217
204
|
event.preventDefault();
|
|
218
|
-
|
|
219
205
|
if (value != null) {
|
|
220
206
|
// nb. we explicitly check against null/undefined
|
|
221
207
|
dialog.close(value);
|
|
@@ -237,38 +223,39 @@ function dialogPolyfillInfo(dialog) {
|
|
|
237
223
|
if (!dialog.hasAttribute('role')) {
|
|
238
224
|
dialog.setAttribute('role', 'dialog');
|
|
239
225
|
}
|
|
240
|
-
|
|
241
226
|
dialog.show = this.show.bind(this);
|
|
242
227
|
dialog.showModal = this.showModal.bind(this);
|
|
243
228
|
dialog.close = this.close.bind(this);
|
|
244
|
-
|
|
245
229
|
dialog.addEventListener('submit', maybeHandleSubmit, false);
|
|
246
|
-
|
|
247
230
|
if (!('returnValue' in dialog)) {
|
|
248
231
|
dialog.returnValue = '';
|
|
249
232
|
}
|
|
250
|
-
|
|
251
233
|
if ('MutationObserver' in window) {
|
|
252
234
|
var mo = new MutationObserver(this.maybeHideModal.bind(this));
|
|
253
|
-
mo.observe(dialog, {
|
|
235
|
+
mo.observe(dialog, {
|
|
236
|
+
attributes: true,
|
|
237
|
+
attributeFilter: ['open']
|
|
238
|
+
});
|
|
254
239
|
} else {
|
|
255
240
|
// IE10 and below support. Note that DOMNodeRemoved etc fire _before_ removal. They also
|
|
256
241
|
// seem to fire even if the element was removed as part of a parent removal. Use the removed
|
|
257
242
|
// events to force downgrade (useful if removed/immediately added).
|
|
258
243
|
var removed = false;
|
|
259
|
-
var cb = function() {
|
|
244
|
+
var cb = function () {
|
|
260
245
|
removed ? this.downgradeModal() : this.maybeHideModal();
|
|
261
246
|
removed = false;
|
|
262
247
|
}.bind(this);
|
|
263
248
|
var timeout;
|
|
264
|
-
var delayModel = function(ev) {
|
|
265
|
-
if (ev.target !== dialog) {
|
|
249
|
+
var delayModel = function (ev) {
|
|
250
|
+
if (ev.target !== dialog) {
|
|
251
|
+
return;
|
|
252
|
+
} // not for a child element
|
|
266
253
|
var cand = 'DOMNodeRemoved';
|
|
267
|
-
removed |=
|
|
254
|
+
removed |= ev.type.substr(0, cand.length) === cand;
|
|
268
255
|
window.clearTimeout(timeout);
|
|
269
256
|
timeout = window.setTimeout(cb, 0);
|
|
270
257
|
};
|
|
271
|
-
['DOMAttrModified', 'DOMNodeRemoved', 'DOMNodeRemovedFromDocument'].forEach(function(name) {
|
|
258
|
+
['DOMAttrModified', 'DOMNodeRemoved', 'DOMNodeRemovedFromDocument'].forEach(function (name) {
|
|
272
259
|
dialog.addEventListener(name, delayModel);
|
|
273
260
|
});
|
|
274
261
|
}
|
|
@@ -279,35 +266,34 @@ function dialogPolyfillInfo(dialog) {
|
|
|
279
266
|
set: this.setOpen.bind(this),
|
|
280
267
|
get: dialog.hasAttribute.bind(dialog, 'open')
|
|
281
268
|
});
|
|
282
|
-
|
|
283
269
|
this.backdrop_ = document.createElement('div');
|
|
284
270
|
this.backdrop_.className = 'backdrop';
|
|
285
|
-
this.backdrop_.addEventListener('mouseup'
|
|
271
|
+
this.backdrop_.addEventListener('mouseup', this.backdropMouseEvent_.bind(this));
|
|
286
272
|
this.backdrop_.addEventListener('mousedown', this.backdropMouseEvent_.bind(this));
|
|
287
|
-
this.backdrop_.addEventListener('click'
|
|
273
|
+
this.backdrop_.addEventListener('click', this.backdropMouseEvent_.bind(this));
|
|
288
274
|
}
|
|
289
|
-
|
|
290
|
-
dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ ({
|
|
291
|
-
|
|
275
|
+
dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */{
|
|
292
276
|
get dialog() {
|
|
293
277
|
return this.dialog_;
|
|
294
278
|
},
|
|
295
|
-
|
|
296
279
|
/**
|
|
297
280
|
* Maybe remove this dialog from the modal top layer. This is called when
|
|
298
281
|
* a modal dialog may no longer be tenable, e.g., when the dialog is no
|
|
299
282
|
* longer open or is no longer part of the DOM.
|
|
300
283
|
*/
|
|
301
|
-
maybeHideModal: function() {
|
|
302
|
-
if (this.dialog_.hasAttribute('open') && isConnected(this.dialog_)) {
|
|
284
|
+
maybeHideModal: function () {
|
|
285
|
+
if (this.dialog_.hasAttribute('open') && isConnected(this.dialog_)) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
303
288
|
this.downgradeModal();
|
|
304
289
|
},
|
|
305
|
-
|
|
306
290
|
/**
|
|
307
291
|
* Remove this dialog from the modal top layer, leaving it as a non-modal.
|
|
308
292
|
*/
|
|
309
|
-
downgradeModal: function() {
|
|
310
|
-
if (!this.openAsModal_) {
|
|
293
|
+
downgradeModal: function () {
|
|
294
|
+
if (!this.openAsModal_) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
311
297
|
this.openAsModal_ = false;
|
|
312
298
|
this.dialog_.style.zIndex = '';
|
|
313
299
|
|
|
@@ -323,16 +309,15 @@ dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ ({
|
|
|
323
309
|
this.backdrop_.parentNode && this.backdrop_.parentNode.removeChild(this.backdrop_);
|
|
324
310
|
dialogPolyfill.dm.removeDialog(this);
|
|
325
311
|
},
|
|
326
|
-
|
|
327
312
|
/**
|
|
328
313
|
* @param {boolean} value whether to open or close this dialog
|
|
329
314
|
*/
|
|
330
|
-
setOpen: function(value) {
|
|
315
|
+
setOpen: function (value) {
|
|
331
316
|
if (value) {
|
|
332
317
|
this.dialog_.hasAttribute('open') || this.dialog_.setAttribute('open', '');
|
|
333
318
|
} else {
|
|
334
319
|
this.dialog_.removeAttribute('open');
|
|
335
|
-
this.maybeHideModal();
|
|
320
|
+
this.maybeHideModal(); // nb. redundant with MutationObserver
|
|
336
321
|
}
|
|
337
322
|
},
|
|
338
323
|
|
|
@@ -342,7 +327,7 @@ dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ ({
|
|
|
342
327
|
*
|
|
343
328
|
* @param {!Event} e to redirect
|
|
344
329
|
*/
|
|
345
|
-
backdropMouseEvent_: function(e) {
|
|
330
|
+
backdropMouseEvent_: function (e) {
|
|
346
331
|
if (!this.dialog_.hasAttribute('tabindex')) {
|
|
347
332
|
// Clicking on the backdrop should move the implicit cursor, even if dialog cannot be
|
|
348
333
|
// focused. Create a fake thing to focus on. If the backdrop was _before_ the dialog, this
|
|
@@ -355,20 +340,16 @@ dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ ({
|
|
|
355
340
|
} else {
|
|
356
341
|
this.dialog_.focus();
|
|
357
342
|
}
|
|
358
|
-
|
|
359
343
|
var redirectedEvent = document.createEvent('MouseEvents');
|
|
360
|
-
redirectedEvent.initMouseEvent(e.type, e.bubbles, e.cancelable, window,
|
|
361
|
-
e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey,
|
|
362
|
-
e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
|
|
344
|
+
redirectedEvent.initMouseEvent(e.type, e.bubbles, e.cancelable, window, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
|
|
363
345
|
this.dialog_.dispatchEvent(redirectedEvent);
|
|
364
346
|
e.stopPropagation();
|
|
365
347
|
},
|
|
366
|
-
|
|
367
348
|
/**
|
|
368
349
|
* Focuses on the first focusable element within the dialog. This will always blur the current
|
|
369
350
|
* focus, even if nothing within the dialog is found.
|
|
370
351
|
*/
|
|
371
|
-
focus_: function() {
|
|
352
|
+
focus_: function () {
|
|
372
353
|
// Find element with `autofocus` attribute, or fall back to the first form/tabindex control.
|
|
373
354
|
var target = this.dialog_.querySelector('[autofocus]:not([disabled])');
|
|
374
355
|
if (!target && this.dialog_.tabIndex >= 0) {
|
|
@@ -380,35 +361,32 @@ dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ ({
|
|
|
380
361
|
safeBlur(document.activeElement);
|
|
381
362
|
target && target.focus();
|
|
382
363
|
},
|
|
383
|
-
|
|
384
364
|
/**
|
|
385
365
|
* Sets the zIndex for the backdrop and dialog.
|
|
386
366
|
*
|
|
387
367
|
* @param {number} dialogZ
|
|
388
368
|
* @param {number} backdropZ
|
|
389
369
|
*/
|
|
390
|
-
updateZIndex: function(dialogZ, backdropZ) {
|
|
370
|
+
updateZIndex: function (dialogZ, backdropZ) {
|
|
391
371
|
if (dialogZ < backdropZ) {
|
|
392
372
|
throw new Error('dialogZ should never be < backdropZ');
|
|
393
373
|
}
|
|
394
374
|
this.dialog_.style.zIndex = dialogZ;
|
|
395
375
|
this.backdrop_.style.zIndex = backdropZ;
|
|
396
376
|
},
|
|
397
|
-
|
|
398
377
|
/**
|
|
399
378
|
* Shows the dialog. If the dialog is already open, this does nothing.
|
|
400
379
|
*/
|
|
401
|
-
show: function() {
|
|
380
|
+
show: function () {
|
|
402
381
|
if (!this.dialog_.open) {
|
|
403
382
|
this.setOpen(true);
|
|
404
383
|
this.focus_();
|
|
405
384
|
}
|
|
406
385
|
},
|
|
407
|
-
|
|
408
386
|
/**
|
|
409
387
|
* Show this dialog modally.
|
|
410
388
|
*/
|
|
411
|
-
showModal: function() {
|
|
389
|
+
showModal: function () {
|
|
412
390
|
if (this.dialog_.hasAttribute('open')) {
|
|
413
391
|
throw new Error('Failed to execute \'showModal\' on dialog: The element is already open, and therefore cannot be opened modally.');
|
|
414
392
|
}
|
|
@@ -418,13 +396,9 @@ dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ ({
|
|
|
418
396
|
if (!dialogPolyfill.dm.pushDialog(this)) {
|
|
419
397
|
throw new Error('Failed to execute \'showModal\' on dialog: There are too many open modal dialogs.');
|
|
420
398
|
}
|
|
421
|
-
|
|
422
399
|
if (createsStackingContext(this.dialog_.parentElement)) {
|
|
423
|
-
console.warn('A dialog is being shown inside a stacking context. ' +
|
|
424
|
-
'This may cause it to be unusable. For more information, see this link: ' +
|
|
425
|
-
'https://github.com/GoogleChrome/dialog-polyfill/#stacking-context');
|
|
400
|
+
console.warn('A dialog is being shown inside a stacking context. ' + 'This may cause it to be unusable. For more information, see this link: ' + 'https://github.com/GoogleChrome/dialog-polyfill/#stacking-context');
|
|
426
401
|
}
|
|
427
|
-
|
|
428
402
|
this.setOpen(true);
|
|
429
403
|
this.openAsModal_ = true;
|
|
430
404
|
|
|
@@ -442,14 +416,13 @@ dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ ({
|
|
|
442
416
|
// Focus on whatever inside the dialog.
|
|
443
417
|
this.focus_();
|
|
444
418
|
},
|
|
445
|
-
|
|
446
419
|
/**
|
|
447
420
|
* Closes this HTMLDialogElement. This is optional vs clearing the open
|
|
448
421
|
* attribute, however this fires a 'close' event.
|
|
449
422
|
*
|
|
450
423
|
* @param {string=} opt_returnValue to use as the returnValue
|
|
451
424
|
*/
|
|
452
|
-
close: function(opt_returnValue) {
|
|
425
|
+
close: function (opt_returnValue) {
|
|
453
426
|
if (!this.dialog_.hasAttribute('open')) {
|
|
454
427
|
throw new Error('Failed to execute \'close\' on dialog: The element does not have an \'open\' attribute, and therefore cannot be closed.');
|
|
455
428
|
}
|
|
@@ -467,18 +440,14 @@ dialogPolyfillInfo.prototype = /** @type {HTMLDialogElement.prototype} */ ({
|
|
|
467
440
|
});
|
|
468
441
|
safeDispatchEvent(this.dialog_, closeEvent);
|
|
469
442
|
}
|
|
470
|
-
|
|
471
|
-
});
|
|
472
|
-
|
|
443
|
+
};
|
|
473
444
|
var dialogPolyfill = {};
|
|
474
|
-
|
|
475
|
-
dialogPolyfill.reposition = function(element) {
|
|
445
|
+
dialogPolyfill.reposition = function (element) {
|
|
476
446
|
var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
|
|
477
447
|
var topValue = scrollTop + (window.innerHeight - element.offsetHeight) / 2;
|
|
478
448
|
element.style.top = Math.max(scrollTop, topValue) + 'px';
|
|
479
449
|
};
|
|
480
|
-
|
|
481
|
-
dialogPolyfill.isInlinePositionSetByStylesheet = function(element) {
|
|
450
|
+
dialogPolyfill.isInlinePositionSetByStylesheet = function (element) {
|
|
482
451
|
for (var i = 0; i < document.styleSheets.length; ++i) {
|
|
483
452
|
var styleSheet = document.styleSheets[i];
|
|
484
453
|
var cssRules = null;
|
|
@@ -486,28 +455,29 @@ dialogPolyfill.isInlinePositionSetByStylesheet = function(element) {
|
|
|
486
455
|
try {
|
|
487
456
|
cssRules = styleSheet.cssRules;
|
|
488
457
|
} catch (e) {}
|
|
489
|
-
if (!cssRules) {
|
|
458
|
+
if (!cssRules) {
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
490
461
|
for (var j = 0; j < cssRules.length; ++j) {
|
|
491
462
|
var rule = cssRules[j];
|
|
492
463
|
var selectedNodes = null;
|
|
493
464
|
// Ignore errors on invalid selector texts.
|
|
494
465
|
try {
|
|
495
466
|
selectedNodes = document.querySelectorAll(rule.selectorText);
|
|
496
|
-
} catch(e) {}
|
|
467
|
+
} catch (e) {}
|
|
497
468
|
if (!selectedNodes || !inNodeList(selectedNodes, element)) {
|
|
498
469
|
continue;
|
|
499
470
|
}
|
|
500
471
|
var cssTop = rule.style.getPropertyValue('top');
|
|
501
472
|
var cssBottom = rule.style.getPropertyValue('bottom');
|
|
502
|
-
if (
|
|
473
|
+
if (cssTop && cssTop !== 'auto' || cssBottom && cssBottom !== 'auto') {
|
|
503
474
|
return true;
|
|
504
475
|
}
|
|
505
476
|
}
|
|
506
477
|
}
|
|
507
478
|
return false;
|
|
508
479
|
};
|
|
509
|
-
|
|
510
|
-
dialogPolyfill.needsCentering = function(dialog) {
|
|
480
|
+
dialogPolyfill.needsCentering = function (dialog) {
|
|
511
481
|
var computedStyle = window.getComputedStyle(dialog);
|
|
512
482
|
if (computedStyle.position !== 'absolute') {
|
|
513
483
|
return false;
|
|
@@ -517,8 +487,7 @@ dialogPolyfill.needsCentering = function(dialog) {
|
|
|
517
487
|
// WebKit/Blink, checking computedStyle.top == 'auto' is sufficient, but
|
|
518
488
|
// Firefox returns the used value. So we do this crazy thing instead: check
|
|
519
489
|
// the inline style and then go through CSS rules.
|
|
520
|
-
if (
|
|
521
|
-
(dialog.style.bottom !== 'auto' && dialog.style.bottom !== '')) {
|
|
490
|
+
if (dialog.style.top !== 'auto' && dialog.style.top !== '' || dialog.style.bottom !== 'auto' && dialog.style.bottom !== '') {
|
|
522
491
|
return false;
|
|
523
492
|
}
|
|
524
493
|
return !dialogPolyfill.isInlinePositionSetByStylesheet(dialog);
|
|
@@ -527,21 +496,20 @@ dialogPolyfill.needsCentering = function(dialog) {
|
|
|
527
496
|
/**
|
|
528
497
|
* @param {!Element} element to force upgrade
|
|
529
498
|
*/
|
|
530
|
-
dialogPolyfill.forceRegisterDialog = function(element) {
|
|
499
|
+
dialogPolyfill.forceRegisterDialog = function (element) {
|
|
531
500
|
if (window.HTMLDialogElement || element.showModal) {
|
|
532
|
-
console.warn('This browser already supports <dialog>, the polyfill ' +
|
|
533
|
-
'may not work correctly', element);
|
|
501
|
+
console.warn('This browser already supports <dialog>, the polyfill ' + 'may not work correctly', element);
|
|
534
502
|
}
|
|
535
503
|
if (element.localName !== 'dialog') {
|
|
536
504
|
throw new Error('Failed to register dialog: The element is not a dialog.');
|
|
537
505
|
}
|
|
538
|
-
new dialogPolyfillInfo(/** @type {!HTMLDialogElement} */
|
|
506
|
+
new dialogPolyfillInfo( /** @type {!HTMLDialogElement} */element);
|
|
539
507
|
};
|
|
540
508
|
|
|
541
509
|
/**
|
|
542
510
|
* @param {!Element} element to upgrade, if necessary
|
|
543
511
|
*/
|
|
544
|
-
dialogPolyfill.registerDialog = function(element) {
|
|
512
|
+
dialogPolyfill.registerDialog = function (element) {
|
|
545
513
|
if (!element.showModal) {
|
|
546
514
|
dialogPolyfill.forceRegisterDialog(element);
|
|
547
515
|
}
|
|
@@ -550,10 +518,9 @@ dialogPolyfill.registerDialog = function(element) {
|
|
|
550
518
|
/**
|
|
551
519
|
* @constructor
|
|
552
520
|
*/
|
|
553
|
-
dialogPolyfill.DialogManager = function() {
|
|
521
|
+
dialogPolyfill.DialogManager = function () {
|
|
554
522
|
/** @type {!Array<!dialogPolyfillInfo>} */
|
|
555
523
|
this.pendingDialogStack = [];
|
|
556
|
-
|
|
557
524
|
var checkDOM = this.checkDOM_.bind(this);
|
|
558
525
|
|
|
559
526
|
// The overlay is used to simulate how a modal dialog blocks the document.
|
|
@@ -563,24 +530,20 @@ dialogPolyfill.DialogManager = function() {
|
|
|
563
530
|
// top layer, where z-index has no effect.
|
|
564
531
|
this.overlay = document.createElement('div');
|
|
565
532
|
this.overlay.className = '_dialog_overlay';
|
|
566
|
-
this.overlay.addEventListener('click', function(e) {
|
|
533
|
+
this.overlay.addEventListener('click', function (e) {
|
|
567
534
|
this.forwardTab_ = undefined;
|
|
568
535
|
e.stopPropagation();
|
|
569
|
-
checkDOM([]);
|
|
536
|
+
checkDOM([]); // sanity-check DOM
|
|
570
537
|
}.bind(this));
|
|
571
|
-
|
|
572
538
|
this.handleKey_ = this.handleKey_.bind(this);
|
|
573
539
|
this.handleFocus_ = this.handleFocus_.bind(this);
|
|
574
|
-
|
|
575
540
|
this.zIndexLow_ = 100000;
|
|
576
541
|
this.zIndexHigh_ = 100000 + 150;
|
|
577
|
-
|
|
578
542
|
this.forwardTab_ = undefined;
|
|
579
|
-
|
|
580
543
|
if ('MutationObserver' in window) {
|
|
581
|
-
this.mo_ = new MutationObserver(function(records) {
|
|
544
|
+
this.mo_ = new MutationObserver(function (records) {
|
|
582
545
|
var removed = [];
|
|
583
|
-
records.forEach(function(rec) {
|
|
546
|
+
records.forEach(function (rec) {
|
|
584
547
|
for (var i = 0, c; c = rec.removedNodes[i]; ++i) {
|
|
585
548
|
if (!(c instanceof Element)) {
|
|
586
549
|
continue;
|
|
@@ -599,17 +562,20 @@ dialogPolyfill.DialogManager = function() {
|
|
|
599
562
|
* Called on the first modal dialog being shown. Adds the overlay and related
|
|
600
563
|
* handlers.
|
|
601
564
|
*/
|
|
602
|
-
dialogPolyfill.DialogManager.prototype.blockDocument = function() {
|
|
565
|
+
dialogPolyfill.DialogManager.prototype.blockDocument = function () {
|
|
603
566
|
document.documentElement.addEventListener('focus', this.handleFocus_, true);
|
|
604
567
|
document.addEventListener('keydown', this.handleKey_);
|
|
605
|
-
this.mo_ && this.mo_.observe(document, {
|
|
568
|
+
this.mo_ && this.mo_.observe(document, {
|
|
569
|
+
childList: true,
|
|
570
|
+
subtree: true
|
|
571
|
+
});
|
|
606
572
|
};
|
|
607
573
|
|
|
608
574
|
/**
|
|
609
575
|
* Called on the first modal dialog being removed, i.e., when no more modal
|
|
610
576
|
* dialogs are visible.
|
|
611
577
|
*/
|
|
612
|
-
dialogPolyfill.DialogManager.prototype.unblockDocument = function() {
|
|
578
|
+
dialogPolyfill.DialogManager.prototype.unblockDocument = function () {
|
|
613
579
|
document.documentElement.removeEventListener('focus', this.handleFocus_, true);
|
|
614
580
|
document.removeEventListener('keydown', this.handleKey_);
|
|
615
581
|
this.mo_ && this.mo_.disconnect();
|
|
@@ -618,9 +584,8 @@ dialogPolyfill.DialogManager.prototype.unblockDocument = function() {
|
|
|
618
584
|
/**
|
|
619
585
|
* Updates the stacking of all known dialogs.
|
|
620
586
|
*/
|
|
621
|
-
dialogPolyfill.DialogManager.prototype.updateStacking = function() {
|
|
587
|
+
dialogPolyfill.DialogManager.prototype.updateStacking = function () {
|
|
622
588
|
var zIndex = this.zIndexHigh_;
|
|
623
|
-
|
|
624
589
|
for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
|
|
625
590
|
dpi.updateZIndex(--zIndex, --zIndex);
|
|
626
591
|
if (i === 0) {
|
|
@@ -642,30 +607,32 @@ dialogPolyfill.DialogManager.prototype.updateStacking = function() {
|
|
|
642
607
|
* @param {Element} candidate to check if contained or is the top-most modal dialog
|
|
643
608
|
* @return {boolean} whether candidate is contained in top dialog
|
|
644
609
|
*/
|
|
645
|
-
dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function(candidate) {
|
|
610
|
+
dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function (candidate) {
|
|
646
611
|
while (candidate = findNearestDialog(candidate)) {
|
|
647
612
|
for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
|
|
648
613
|
if (dpi.dialog === candidate) {
|
|
649
|
-
return i === 0;
|
|
614
|
+
return i === 0; // only valid if top-most
|
|
650
615
|
}
|
|
651
616
|
}
|
|
617
|
+
|
|
652
618
|
candidate = candidate.parentElement;
|
|
653
619
|
}
|
|
654
620
|
return false;
|
|
655
621
|
};
|
|
656
|
-
|
|
657
|
-
dialogPolyfill.DialogManager.prototype.handleFocus_ = function(event) {
|
|
622
|
+
dialogPolyfill.DialogManager.prototype.handleFocus_ = function (event) {
|
|
658
623
|
var target = event.composedPath ? event.composedPath()[0] : event.target;
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
if (document.activeElement === document.documentElement) {
|
|
663
|
-
|
|
624
|
+
if (this.containedByTopDialog_(target)) {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
if (document.activeElement === document.documentElement) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
664
630
|
event.preventDefault();
|
|
665
631
|
event.stopPropagation();
|
|
666
|
-
safeBlur(/** @type {Element} */
|
|
667
|
-
|
|
668
|
-
|
|
632
|
+
safeBlur( /** @type {Element} */target);
|
|
633
|
+
if (this.forwardTab_ === undefined) {
|
|
634
|
+
return;
|
|
635
|
+
} // move focus only from a tab key
|
|
669
636
|
|
|
670
637
|
var dpi = this.pendingDialogStack[0];
|
|
671
638
|
var dialog = dpi.dialog;
|
|
@@ -679,11 +646,9 @@ dialogPolyfill.DialogManager.prototype.handleFocus_ = function(event) {
|
|
|
679
646
|
document.documentElement.focus();
|
|
680
647
|
}
|
|
681
648
|
}
|
|
682
|
-
|
|
683
649
|
return false;
|
|
684
650
|
};
|
|
685
|
-
|
|
686
|
-
dialogPolyfill.DialogManager.prototype.handleKey_ = function(event) {
|
|
651
|
+
dialogPolyfill.DialogManager.prototype.handleKey_ = function (event) {
|
|
687
652
|
this.forwardTab_ = undefined;
|
|
688
653
|
if (event.keyCode === 27) {
|
|
689
654
|
event.preventDefault();
|
|
@@ -707,12 +672,12 @@ dialogPolyfill.DialogManager.prototype.handleKey_ = function(event) {
|
|
|
707
672
|
*
|
|
708
673
|
* @param {!Array<!HTMLDialogElement>} removed that have definitely been removed
|
|
709
674
|
*/
|
|
710
|
-
dialogPolyfill.DialogManager.prototype.checkDOM_ = function(removed) {
|
|
675
|
+
dialogPolyfill.DialogManager.prototype.checkDOM_ = function (removed) {
|
|
711
676
|
// This operates on a clone because it may cause it to change. Each change also calls
|
|
712
677
|
// updateStacking, which only actually needs to happen once. But who removes many modal dialogs
|
|
713
678
|
// at a time?!
|
|
714
679
|
var clone = this.pendingDialogStack.slice();
|
|
715
|
-
clone.forEach(function(dpi) {
|
|
680
|
+
clone.forEach(function (dpi) {
|
|
716
681
|
if (removed.indexOf(dpi.dialog) !== -1) {
|
|
717
682
|
dpi.downgradeModal();
|
|
718
683
|
} else {
|
|
@@ -725,7 +690,7 @@ dialogPolyfill.DialogManager.prototype.checkDOM_ = function(removed) {
|
|
|
725
690
|
* @param {!dialogPolyfillInfo} dpi
|
|
726
691
|
* @return {boolean} whether the dialog was allowed
|
|
727
692
|
*/
|
|
728
|
-
dialogPolyfill.DialogManager.prototype.pushDialog = function(dpi) {
|
|
693
|
+
dialogPolyfill.DialogManager.prototype.pushDialog = function (dpi) {
|
|
729
694
|
var allowed = (this.zIndexHigh_ - this.zIndexLow_) / 2 - 1;
|
|
730
695
|
if (this.pendingDialogStack.length >= allowed) {
|
|
731
696
|
return false;
|
|
@@ -740,17 +705,17 @@ dialogPolyfill.DialogManager.prototype.pushDialog = function(dpi) {
|
|
|
740
705
|
/**
|
|
741
706
|
* @param {!dialogPolyfillInfo} dpi
|
|
742
707
|
*/
|
|
743
|
-
dialogPolyfill.DialogManager.prototype.removeDialog = function(dpi) {
|
|
708
|
+
dialogPolyfill.DialogManager.prototype.removeDialog = function (dpi) {
|
|
744
709
|
var index = this.pendingDialogStack.indexOf(dpi);
|
|
745
|
-
if (index === -1) {
|
|
746
|
-
|
|
710
|
+
if (index === -1) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
747
713
|
this.pendingDialogStack.splice(index, 1);
|
|
748
714
|
if (this.pendingDialogStack.length === 0) {
|
|
749
715
|
this.unblockDocument();
|
|
750
716
|
}
|
|
751
717
|
this.updateStacking();
|
|
752
718
|
};
|
|
753
|
-
|
|
754
719
|
dialogPolyfill.dm = new dialogPolyfill.DialogManager();
|
|
755
720
|
dialogPolyfill.formSubmitter = null;
|
|
756
721
|
dialogPolyfill.imagemapUseValue = null;
|
|
@@ -760,7 +725,6 @@ dialogPolyfill.imagemapUseValue = null;
|
|
|
760
725
|
* even if a no dialog is registered, as they deal with <form method="dialog">.
|
|
761
726
|
*/
|
|
762
727
|
if (window.HTMLDialogElement === undefined) {
|
|
763
|
-
|
|
764
728
|
/**
|
|
765
729
|
* If HTMLFormElement translates method="DIALOG" into 'get', then replace the descriptor with
|
|
766
730
|
* one that returns the correct value.
|
|
@@ -773,7 +737,7 @@ if (window.HTMLDialogElement === undefined) {
|
|
|
773
737
|
// nb. Some older iOS and older PhantomJS fail to return the descriptor. Don't do anything
|
|
774
738
|
// and don't bother to update the element.
|
|
775
739
|
var realGet = methodDescriptor.get;
|
|
776
|
-
methodDescriptor.get = function() {
|
|
740
|
+
methodDescriptor.get = function () {
|
|
777
741
|
if (isFormMethodDialog(this)) {
|
|
778
742
|
return 'dialog';
|
|
779
743
|
}
|
|
@@ -781,7 +745,7 @@ if (window.HTMLDialogElement === undefined) {
|
|
|
781
745
|
};
|
|
782
746
|
var realSet = methodDescriptor.set;
|
|
783
747
|
/** @this {HTMLElement} */
|
|
784
|
-
methodDescriptor.set = function(v) {
|
|
748
|
+
methodDescriptor.set = function (v) {
|
|
785
749
|
if (typeof v === 'string' && v.toLowerCase() === 'dialog') {
|
|
786
750
|
return this.setAttribute('method', v);
|
|
787
751
|
}
|
|
@@ -796,41 +760,45 @@ if (window.HTMLDialogElement === undefined) {
|
|
|
796
760
|
* submitted a <form method="dialog">. Needed as Safari and others don't report this inside
|
|
797
761
|
* document.activeElement.
|
|
798
762
|
*/
|
|
799
|
-
document.addEventListener('click', function(ev) {
|
|
763
|
+
document.addEventListener('click', function (ev) {
|
|
800
764
|
dialogPolyfill.formSubmitter = null;
|
|
801
765
|
dialogPolyfill.imagemapUseValue = null;
|
|
802
|
-
if (ev.defaultPrevented) {
|
|
766
|
+
if (ev.defaultPrevented) {
|
|
767
|
+
return;
|
|
768
|
+
} // e.g. a submit which prevents default submission
|
|
803
769
|
|
|
804
|
-
var target = /** @type {Element} */
|
|
770
|
+
var target = /** @type {Element} */ev.target;
|
|
805
771
|
if ('composedPath' in ev) {
|
|
806
772
|
var path = ev.composedPath();
|
|
807
773
|
target = path.shift() || target;
|
|
808
774
|
}
|
|
809
|
-
if (!target || !isFormMethodDialog(target.form)) {
|
|
810
|
-
|
|
811
|
-
|
|
775
|
+
if (!target || !isFormMethodDialog(target.form)) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
var valid = target.type === 'submit' && ['button', 'input'].indexOf(target.localName) > -1;
|
|
812
779
|
if (!valid) {
|
|
813
|
-
if (!(target.localName === 'input' && target.type === 'image')) {
|
|
780
|
+
if (!(target.localName === 'input' && target.type === 'image')) {
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
814
783
|
// this is a <input type="image">, which can submit forms
|
|
815
784
|
dialogPolyfill.imagemapUseValue = ev.offsetX + ',' + ev.offsetY;
|
|
816
785
|
}
|
|
817
|
-
|
|
818
786
|
var dialog = findNearestDialog(target);
|
|
819
|
-
if (!dialog) {
|
|
820
|
-
|
|
787
|
+
if (!dialog) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
821
790
|
dialogPolyfill.formSubmitter = target;
|
|
822
|
-
|
|
823
791
|
}, false);
|
|
824
792
|
|
|
825
793
|
/**
|
|
826
794
|
* Global 'submit' handler. This handles submits of `method="dialog"` which are invalid, i.e.,
|
|
827
795
|
* outside a dialog. They get prevented.
|
|
828
796
|
*/
|
|
829
|
-
document.addEventListener('submit', function(ev) {
|
|
797
|
+
document.addEventListener('submit', function (ev) {
|
|
830
798
|
var form = ev.target;
|
|
831
799
|
var dialog = findNearestDialog(form);
|
|
832
800
|
if (dialog) {
|
|
833
|
-
return;
|
|
801
|
+
return; // ignore, handle there
|
|
834
802
|
}
|
|
835
803
|
|
|
836
804
|
var submitter = findFormSubmitter(ev);
|