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

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

Loading…
Cancel
Save