Skip to content

Yield out potentional slot instructions when rendering dynamic tags#4981

Merged
matthewp merged 6 commits intomainfrom
render-dynamic-tag
Oct 5, 2022
Merged

Yield out potentional slot instructions when rendering dynamic tags#4981
matthewp merged 6 commits intomainfrom
render-dynamic-tag

Conversation

@matthewp
Copy link
Copy Markdown
Contributor

@matthewp matthewp commented Oct 4, 2022

Changes

Testing

  • Fixture test added

Docs

N/A, bug fix

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Oct 4, 2022

🦋 Changeset detected

Latest commit: c586942

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Oct 4, 2022
@matthewp matthewp force-pushed the render-dynamic-tag branch from f70941a to c586942 Compare October 5, 2022 18:07
@natemoo-re
Copy link
Copy Markdown
Member

!bench

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 5, 2022

Node: 14
PR: �[0m[1]�[0m 23k requests in 30.11s, 1.54 GB read
MAIN: �[0m[1]�[0m 23k requests in 30.1s, 1.56 GB read


Node: 16
PR: �[0m[1]�[0m 22k requests in 30.07s, 1.47 GB read
MAIN: �[0m[1]�[0m 22k requests in 30.11s, 1.48 GB read

Copy link
Copy Markdown
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming the bench deviation is not significant!

@matthewp
Copy link
Copy Markdown
Contributor Author

matthewp commented Oct 5, 2022

I really love that command. Just need to clean up the output a little bit.

@matthewp matthewp merged commit 1f890b3 into main Oct 5, 2022
@matthewp matthewp deleted the render-dynamic-tag branch October 5, 2022 20:30
@astrobot-houston astrobot-houston mentioned this pull request Oct 5, 2022
let i = 0;
for await (const chunk of iterable) {
if (isHTMLString(chunk)) {
if (i === 0) {
Copy link
Copy Markdown
Contributor

@aFuzzyBear aFuzzyBear Oct 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cant see where i is being incremented within the for of loop, it reads *forgive me, as a unnecessary conditional check, I mean its perhaps somewhere but I just cant see it from here,

Copy link
Copy Markdown
Contributor

@aFuzzyBear aFuzzyBear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Matt, I am sorry I know this is merged, but I was taking a wee look over this, just doing some studying, and I got stumped on a few things. predomately with the iterableToHTMLBytes now Im not pretending to understand whats going on, kinda got a wee sense, but two things struck out to me.

  1. The logic is very nested, having looked at it I was wondering if it could be less deep
for await (const chunk of iterable) {
-		if (isHTMLString(chunk)) {
-			if (i === 0) {

-				if (!/<!doctype html/i.test(String(chunk))) {
+		if ( isHTMLString(chunk)
+             && i === 0
+             && !/<!doctype html/i.test(String(chunk))
                ) { parts.append('<!DOCTYPE html>\n', result);
					if(onDocTypeInjection) {
						await onDocTypeInjection(parts);
					}
				}
			}
		}

Also what is i doing exactly, I couldnt see where it gets incremented,

Sorry to take your time with this,

@matthewp
Copy link
Copy Markdown
Contributor Author

matthewp commented Oct 9, 2022

Yeah we can talk about it. Are you investigating because you've encountered a bug you think was caused by this?

@aFuzzyBear
Copy link
Copy Markdown
Contributor

no no, I was doing a wee bit of studying last night, if you got the time dude Id love to understand this whole thing alot better

@matthewp
Copy link
Copy Markdown
Contributor Author

There was a bug that came about from this, fixed here: #5035

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

astro-slot no closed tag and Client Directives Don't work

3 participants