@jqhtml/core 2.3.75 → 2.3.76
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/component.d.ts.map +1 -1
- package/dist/index.cjs +34 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -5
- package/dist/index.js.map +1 -1
- package/dist/jqhtml-core.esm.js +35 -6
- package/dist/jqhtml-core.esm.js.map +1 -1
- package/dist/markup.d.ts +12 -0
- package/dist/markup.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -496,6 +496,32 @@ class Jqhtml_Markup {
|
|
|
496
496
|
this.p = this.instructions.push.bind(this.instructions);
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Whether a buffer emits anything: an element, a component, or text that is not
|
|
501
|
+
* only HTML whitespace (space, tab, LF, FF, CR - a non-breaking space is content).
|
|
502
|
+
* A spliced buffer counts by what it emits itself, so a slot that only forwards
|
|
503
|
+
* an empty slot is empty too. A component counts even if it later renders
|
|
504
|
+
* nothing; that is not knowable without booting it.
|
|
505
|
+
*
|
|
506
|
+
* content() returns '' for a buffer without content: a caller cannot omit a
|
|
507
|
+
* <Slot:> tag conditionally, so writing it empty is how a caller says "nothing
|
|
508
|
+
* here", and it must test falsy like an absent slot.
|
|
509
|
+
*/
|
|
510
|
+
function markup_has_content(markup) {
|
|
511
|
+
for (const instruction of markup.instructions) {
|
|
512
|
+
if (instruction instanceof Jqhtml_Markup) {
|
|
513
|
+
if (markup_has_content(instruction))
|
|
514
|
+
return true;
|
|
515
|
+
}
|
|
516
|
+
else if (instruction !== null && typeof instruction === 'object') {
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
else if (/[^ \t\n\f\r]/.test(String(instruction))) {
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
499
525
|
|
|
500
526
|
/**
|
|
501
527
|
* JQHTML v2 Component Registry
|
|
@@ -1908,7 +1934,7 @@ function serialize_for_cache_key(value) {
|
|
|
1908
1934
|
const class_registry = Object.create(null);
|
|
1909
1935
|
// Markers for serialized class instances (unique to avoid collisions with user data)
|
|
1910
1936
|
// Replaced at build time by rollup (see rollup.config.js).
|
|
1911
|
-
const CORE_VERSION = '2.3.
|
|
1937
|
+
const CORE_VERSION = '2.3.76';
|
|
1912
1938
|
const CLASS_MARKER = '__jqhtml_class__';
|
|
1913
1939
|
const PROPS_MARKER = '__jqhtml_props__';
|
|
1914
1940
|
// How a serialized text is checked for anything the deserialize walk has to act
|
|
@@ -5394,6 +5420,9 @@ class Jqhtml_Component {
|
|
|
5394
5420
|
// console.log('[Component] this.constructor.name:', this.constructor.name);
|
|
5395
5421
|
// console.log('[Component] this.data:', this.data);
|
|
5396
5422
|
// console.log('[Component] this.args:', this.args);
|
|
5423
|
+
// What content() returns: the slot's buffer, or '' when it emits nothing (see
|
|
5424
|
+
// markup_has_content), so a slot written empty tests falsy like an absent one
|
|
5425
|
+
const content_or_empty = (markup) => markup instanceof Jqhtml_Markup && !markup_has_content(markup) ? '' : markup;
|
|
5397
5426
|
// Create content function that handles both default content and named slots
|
|
5398
5427
|
const createContentFunction = () => {
|
|
5399
5428
|
const defaultContentFn = this.args._innerhtml_function;
|
|
@@ -5403,7 +5432,7 @@ class Jqhtml_Component {
|
|
|
5403
5432
|
// If slot name provided and slots object exists, try to use named slot
|
|
5404
5433
|
if (slotName && slotsObj && slotsObj[slotName]) {
|
|
5405
5434
|
// Call the slot function - it returns its markup buffer
|
|
5406
|
-
return slotsObj[slotName](...slotArgs);
|
|
5435
|
+
return content_or_empty(slotsObj[slotName](...slotArgs));
|
|
5407
5436
|
}
|
|
5408
5437
|
// If slot name provided but not found, return empty
|
|
5409
5438
|
else if (slotName) {
|
|
@@ -5411,7 +5440,7 @@ class Jqhtml_Component {
|
|
|
5411
5440
|
}
|
|
5412
5441
|
// No slot name = default content
|
|
5413
5442
|
else if (defaultContentFn) {
|
|
5414
|
-
return defaultContentFn(this);
|
|
5443
|
+
return content_or_empty(defaultContentFn(this));
|
|
5415
5444
|
}
|
|
5416
5445
|
// No content at all
|
|
5417
5446
|
else {
|
|
@@ -5444,7 +5473,7 @@ class Jqhtml_Component {
|
|
|
5444
5473
|
if (childSlots[slotName] && typeof childSlots[slotName] === 'function') {
|
|
5445
5474
|
// Invoke the slot function with everything content() was given; its
|
|
5446
5475
|
// markup buffer is what the template expression handler splices
|
|
5447
|
-
return childSlots[slotName](...slotArgs);
|
|
5476
|
+
return content_or_empty(childSlots[slotName](...slotArgs));
|
|
5448
5477
|
}
|
|
5449
5478
|
// Slot not found, return empty
|
|
5450
5479
|
return '';
|
|
@@ -8924,7 +8953,7 @@ function init(jQuery, config) {
|
|
|
8924
8953
|
}
|
|
8925
8954
|
}
|
|
8926
8955
|
// Version - will be replaced during build with actual version from package.json
|
|
8927
|
-
const version = '2.3.
|
|
8956
|
+
const version = '2.3.76';
|
|
8928
8957
|
// Default export with all functionality
|
|
8929
8958
|
const jqhtml = {
|
|
8930
8959
|
// Core
|