@async/framework 0.3.0 → 0.4.0

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/src/partials.js CHANGED
@@ -46,7 +46,7 @@ export function createPartialRegistry(initialMap = {}, options = {}) {
46
46
  partials: registry
47
47
  };
48
48
  const result = await fn.call(partialContext, props);
49
- return normalizePartialResult(result);
49
+ return normalizePartialResult(result, partialContext);
50
50
  },
51
51
 
52
52
  _adoptMany() {
@@ -58,18 +58,18 @@ export function createPartialRegistry(initialMap = {}, options = {}) {
58
58
  return registry;
59
59
  }
60
60
 
61
- export function normalizePartialResult(result) {
61
+ export function normalizePartialResult(result, context = {}) {
62
62
  if (isPartialEnvelope(result)) {
63
63
  return {
64
64
  ...result,
65
- html: Object.hasOwn(result, "html") ? renderPartialValue(result.html) : result.html
65
+ html: Object.hasOwn(result, "html") ? renderPartialValue(result.html, context) : result.html
66
66
  };
67
67
  }
68
68
 
69
- return { html: renderPartialValue(result) };
69
+ return { html: renderPartialValue(result, context) };
70
70
  }
71
71
 
72
- function renderPartialValue(value) {
72
+ function renderPartialValue(value, context) {
73
73
  if (value?.nodeType) {
74
74
  return value;
75
75
  }
@@ -77,9 +77,17 @@ function renderPartialValue(value) {
77
77
  return value;
78
78
  }
79
79
  if (isTemplateResult(value)) {
80
- return renderTemplate(value);
80
+ return renderTemplate(value, templateRenderOptions(context));
81
81
  }
82
- return renderTemplate(value);
82
+ return renderTemplate(value, templateRenderOptions(context));
83
+ }
84
+
85
+ function templateRenderOptions(context) {
86
+ return {
87
+ attributes: context.loader?.attributes,
88
+ signals: context.signals,
89
+ bind: context.loader?._registerBinding?.bind(context.loader)
90
+ };
83
91
  }
84
92
 
85
93
  function isPartialEnvelope(value) {