Manual cleanup of cramped style

pull/8569/head
S. Elliott Johnson 3 years ago
parent a63a6a4ef0
commit f04902918b

@ -166,6 +166,7 @@ if (typeof HTMLElement === 'function') {
$$props_definition = {};
$$listeners = {};
$$listener_unsubscribe_fns = new Map();
constructor($$componentCtor, $$slots, use_shadow_dom) {
super();
this.$$componentCtor = $$componentCtor;
@ -174,6 +175,7 @@ if (typeof HTMLElement === 'function') {
this.attachShadow({ mode: 'open' });
}
}
addEventListener(type, listener, options) {
// We can't determine upfront if the event is a custom event or not, so we have to
// listen to both. If someone uses a custom event with the same name as a regular
@ -186,6 +188,7 @@ if (typeof HTMLElement === 'function') {
}
super.addEventListener(type, listener, options);
}
removeEventListener(type, listener, options) {
super.removeEventListener(type, listener, options);
if (this.$$component) {
@ -196,6 +199,7 @@ if (typeof HTMLElement === 'function') {
}
}
}
async connectedCallback() {
this.$$connected = true;
if (!this.$$component) {
@ -264,6 +268,7 @@ if (typeof HTMLElement === 'function') {
this.$$listeners = {};
}
}
// We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
// and setting attributes through setAttribute etc, this is helpful
attributeChangedCallback(attr, _oldValue, newValue) {
@ -277,6 +282,7 @@ if (typeof HTMLElement === 'function') {
);
this.$$component.$set({ [attr]: this.$$data[attr] });
}
disconnectedCallback() {
this.$$connected = false;
// In a microtask, because this could be a move within the DOM
@ -287,6 +293,7 @@ if (typeof HTMLElement === 'function') {
}
});
}
$$get_prop_name(attribute_name) {
return (
Object.keys(this.$$props_definition).find(
@ -415,11 +422,13 @@ export class SvelteComponent {
$$ = undefined;
/** */
$$set = undefined;
/** @returns {void} */
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
/** @returns {any} */
$on(type, callback) {
if (!is_function(callback)) {
@ -432,6 +441,7 @@ export class SvelteComponent {
if (index !== -1) callbacks.splice(index, 1);
};
}
/** @returns {void} */
$set($$props) {
if (this.$$set && !is_empty($$props)) {
@ -442,7 +452,8 @@ export class SvelteComponent {
}
}
/** @typedef {Object} CustomElementPropDefinition
/**
* @typedef {Object} CustomElementPropDefinition
* @property {string} [attribute]
* @property {boolean} [reflect]
* @property {'String'|'Boolean'|'Number'|'Array'|'Object'} [type]

@ -1,4 +1,5 @@
import { globals } from './globals';
import { globals } from './globals.js';
/**
* Resize observer singleton.
* One listener per element only!
@ -9,7 +10,9 @@ export class ResizeObserverSingleton {
constructor(options) {
this.options = options;
}
/** @param {Element} element
/**
* @param {Element} element
* @param {Listener} listener
* @returns {() => void}
*/
@ -21,13 +24,17 @@ export class ResizeObserverSingleton {
this._observer.unobserve(element); // this line can probably be removed
};
}
/** @private
/**
* @private
* @readonly
* @default 'WeakMap' in globals ? new WeakMap() : undefined
*/
_listeners = 'WeakMap' in globals ? new WeakMap() : undefined;
/** @private */
_observer = undefined;
/** @private
* @returns {ResizeObserver}
*/
@ -43,25 +50,33 @@ export class ResizeObserverSingleton {
);
}
}
// Needs to be written like this to pass the tree-shake-test
ResizeObserverSingleton.entries = 'WeakMap' in globals ? new WeakMap() : undefined;
/** @typedef {(entry: ResizeObserverEntry) => any} Listener */
/** @typedef {'border-box' | 'content-box' | 'device-pixel-content-box'} ResizeObserverBoxOptions */
/** @typedef {Object} ResizeObserverSize
/**
* @typedef {Object} ResizeObserverSize
* @property {number} blockSize
* @property {number} inlineSize
*/
/** @typedef {Object} ResizeObserverEntry
/**
* @typedef {Object} ResizeObserverEntry
* @property {readonlyResizeObserverSize[]} borderBoxSize
* @property {readonlyResizeObserverSize[]} contentBoxSize
* @property {DOMRectReadOnly} contentRect
* @property {readonlyResizeObserverSize[]} devicePixelContentBoxSize
* @property {Element} target
*/
/** @typedef {Object} ResizeObserverOptions
/**
* @typedef {Object} ResizeObserverOptions
* @property {ResizeObserverBoxOptions} [box]
*/
/** @typedef {Object} ResizeObserver */
/** @typedef {Object} ResizeObserverCallback */

Loading…
Cancel
Save