Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rudimentary innerText function. #3584

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

TKDKid1000
Copy link

After needing the innerText feature for a project of mine, I decided to quickly draft up a mock version of one that could be used. This implementation follows the HTML Standard as best as I could without implementing any complicated layout management tools.

Known missing features:

  • The CSS white-space processing.
  • Hypenation.

Aside from this, my implementation passes the test case shown in MDN's example, as well as a few other personal tests. I know there are improvements needed, but hopefully this can get people started on an implementation.

This mostly fixes #1245.

@TKDKid1000
Copy link
Author

I noticed that a majority of the tests just failed. They passed on my system, and I believe the error was that I accidentally deleted one of the files with the yarn reset-wpt command. I couldn't revoke that change from my commit either, so it will hopefully just be able to be removed before merging. Sorry!

@TKDKid1000
Copy link
Author

This isn't exactly the same as the browser's result, but they are similar enough that this implementation works for most purposes. What follows is an example from a recipe site:

JSDOM

Watch Full Seasons
TV Schedule
Newsletters
Videos
Sweepstakes
Classes
Magazine
Blog
Shows A-Z
Chefs A-Z
Restaurants
Recipes on TV
Recipes
Recipes
Labor Day Cookout Classics
Summer Weeknight Dinners
Ultimate Baking Guide
Healthy Meals + More
On TV
See All Recipes
Recipe of the Day
Grilled Peach Crumble
Trending Recipes
Blackstone Classic Smash Burgers
Summer Pasta with Grilled Eggplant Sauce
Skirt Steak Fajitas
Frozen Strawberry Lemonade Pie
Shows
Shows
TV Schedule
See TV Schedule
See All Shows
Popular Shows
BBQ Brawl
Bobby's Triple Threat
Diners, Drive-Ins and Dives
In the Kitchen
The Pioneer Woman
The Kitchen
Girl Meets Farm
Chefs
Chefs
Chefs & Hosts
Kardea Brown
Ree Drummond
Ina Garten
Sunny Anderson
Bobby Flay
Valerie Bertinelli
Guy Fieri
Molly Yeh
See All Chefs
Trending
Trending
Trending Eats
Newsletters
The Latest
Do Not Drink Borax
Should You Be Jumping on TikTok’s Flavored Water Trend?
This Costco-Themed Birthday Cake Is So Dang Cute
Currently Obsessed With...
Burger King Thailand Released a Cheeseburger That Was Simply a Stack of 20 Cheese Slices Between Two Buns
Pineapple Pepsi Is Coming Back – But You Can Get Only Get It at One Pizza Chain
Shop
Shop
Product Reviews
Gift Ideas
Shop Everything
Newsletter
Shop Now
What's New
6 Black-Owned Spirits Brands You Need To Know
5 Best Splatter Guards, According to a Professional Chef
6 Best Ceramic Cookware Sets, According to Food Network Kitchen
5 Best Quesadilla Makers of 2023, Tested by Food Network Kitchen
The Best Buys from the MacKenzie-Childs Barn Sale
Sweepstakes
Sweepstakes
Fuel for School
$100k Your Way
All Sweepstakes + Contests
Enter Daily for Your Chance to Win $10,000
$100k Your Way Sweepstakes
What's on TV
Home
Recipes
Ina Garten
PREV RECIPE
NEXT RECIPE
Replay
Video

We're sorry, there seems to be an issue playing this video. Please refresh the page or try again in a moment.
If you continue to have issues, please contact us
here
.

WATCH
Loading Video...
Recipe courtesy of
Ina Garten
From:
Barefoot Contessa at Home
Beatty's Chocolate Cake
Getting reviews...
Level:
Intermediate
Total:
1 hr 35 min
Prep:
30 min
Inactive:
30 min
Cook:
35 min
Yield:
8 servings
Nutrition Info
Save Recipe
Pinterest
Email
Ingredients

Deselect All

Butter, for greasing the pans

1 3/4 cups all-purpose flour, plus more for pans

2 cups sugar

3/4 cups good cocoa powder

2 teaspoons baking soda

1 teaspoon baking powder

1 teaspoon kosher salt

1 cup buttermilk, shaken

1/2 cup vegetable oil

2 extra-large eggs, at room temperature

1 teaspoon pure vanilla extract

1 cup freshly brewed hot coffee

Chocolate Buttercream Frosting, recipe follows

Chocolate Frosting:

6 ounces good semisweet chocolate (recommended: Callebaut)

1/2 pound (2 sticks) unsalted butter, at room temperature

1 extra-large egg yolk, at room temperature

1 teaspoon pure vanilla extract

1 1/4 cups sifted confectioners' sugar

1 tablespoon instant coffee powder

Add to Shopping List
View Shopping List
Ingredient Substitutions
Directions
WATCH
Watch how to make this recipe.

Preheat the oven to 350 degrees F. Butter two 8-inch x 2-inch round cake pans. Line with parchment paper, then butter and flour the pans.
Sift the flour, sugar, cocoa, baking soda, baking powder, and salt into the bowl of an electric mixer fitted with a paddle attachment and mix on low speed until combined. In another bowl, combine the buttermilk, oil, eggs, and vanilla. With the mixer on low speed, slowly add the wet ingredients to the dry. With mixer still on low, add the coffee and stir just to combine, scraping the bottom of the bowl with a rubber spatula. Pour the batter into the prepared pans and bake for 35 to 40 minutes, until a cake tester comes out clean. Cool in the pans for 30 minutes, then turn them out onto a cooling rack and cool completely.
Place 1 layer, flat side up, on a flat plate or cake pedestal. With a knife or offset spatula, spread the top with frosting. Place the second layer on top, rounded side up, and spread the frosting evenly on the top and sides of the cake.
Chocolate Frosting:
Chop the chocolate and place it in a heat-proof bowl set over a pan of simmering water. Stir until just melted and set aside until cooled to room temperature.
In the bowl of an electric mixer fitted with a paddle attachment, beat the butter on medium-high speed until light yellow and fluffy, about 3 minutes. Add the egg yolk and vanilla and continue beating for 3 minutes. Turn the mixer to low, gradually add the confectioners' sugar, then beat at medium speed, scraping down the bowl as necessary, until smooth and creamy. Dissolve the coffee powder in 2 teaspoons of the hottest tap water. On low speed, add the chocolate and coffee to the butter mixture and mix until blended. Don't whip! Spread immediately on the cooled cake.

Copyright 2006, Barefoot Contessa at Home, All Rights Reserved

My Private Notes
Add a Note
WATCH
Show:
Barefoot Contessa
Episode:
Flavors and Flowers

Categories:
Chocolate Cake
Cake
Chocolate
Baking
Dessert
Mixer Recipes
Recipes for a Crowd
More from:
Ultimate Baking Guide
Looking for Something Else?
Healthy
Highly Rated
5 Ingredients or Less
Surprise Me
Chocolate Cake
Chocolate Cake
Chocolate Cake
Chocolate Cake
👩‍🍳 What's Cooking

Our Best Healthy Breakfast Ideas

Dishes That Require Very Little Cleanup

Slow Cooker Recipes You'll Love

Discover More Recipes...
What's New

The Best Amazon Prime Day 2023 Kitchen Deals

Top Grocery Sales on Prime Day

What Food Network Editors Are Buying on Prime Day

Our Newsletter

Sign up for the Food Network Shopping Newsletter
Privacy Policy

Sign Up

Related Pages
Mocha Chocolate Icebox Cake Recipe
Chocolate Ganache Cake Recipe
Decadent (Gluten-Free!) Chocolate Cake Recipe
Chocolate Cassis Cake Recipe
Chocolate Cake with Mocha Frosting Recipe
Bittersweet Chocolate Cake Recipe
Site Map
Visitor Agreement
AdChoices
Privacy Notice
About
Newsroom
Advertise
Help
TV Ratings
Online Closed Captioning
California Privacy Notice
Accessibility
Newsletters
Discovery, Inc.
Do Not Sell or Share My Personal Information
International Editions
The Discovery Family of Networks
© 2023 Warner Bros. Discovery, Inc. or its subsidiaries and affiliates. All rights reserved.

Firefox 115.0.3

Recipes
Shows
Chefs
Trending
Shop
Sweepstakes
What's on TV
Home Recipes Ina Garten
PREV RECIPE
NEXT RECIPE
Replay Video

We're sorry, there seems to be an issue playing this video. Please refresh the page or try again in a moment.
If you continue to have issues, please contact us here.

WATCH
Loading Video...
RECIPE COURTESY OF INA GARTEN
From: Barefoot Contessa at Home
Beatty's Chocolate Cake
rated 4.6 of 5 stars
2724 Reviews
Level: Intermediate
Total: 1 hr 35 min
Prep: 30 min
Inactive: 30 min
Cook: 35 min
Yield: 8 servings
Nutrition Info
Save Recipe
Ingredients

Deselect All

Butter, for greasing the pans

1 3/4 cups all-purpose flour, plus more for pans

2 cups sugar

3/4 cups good cocoa powder

2 teaspoons baking soda

1 teaspoon baking powder

1 teaspoon kosher salt

1 cup buttermilk, shaken

1/2 cup vegetable oil

2 extra-large eggs, at room temperature

1 teaspoon pure vanilla extract

1 cup freshly brewed hot coffee

Chocolate Buttercream Frosting, recipe follows

Chocolate Frosting:

6 ounces good semisweet chocolate (recommended: Callebaut)

1/2 pound (2 sticks) unsalted butter, at room temperature

1 extra-large egg yolk, at room temperature

1 teaspoon pure vanilla extract

1 1/4 cups sifted confectioners' sugar

1 tablespoon instant coffee powder

Add to Shopping List
View Shopping List
Ingredient Substitutions
Directions
WATCH
Watch how to make this recipe.
Preheat the oven to 350 degrees F. Butter two 8-inch x 2-inch round cake pans. Line with parchment paper, then butter and flour the pans.
Sift the flour, sugar, cocoa, baking soda, baking powder, and salt into the bowl of an electric mixer fitted with a paddle attachment and mix on low speed until combined. In another bowl, combine the buttermilk, oil, eggs, and vanilla. With the mixer on low speed, slowly add the wet ingredients to the dry. With mixer still on low, add the coffee and stir just to combine, scraping the bottom of the bowl with a rubber spatula. Pour the batter into the prepared pans and bake for 35 to 40 minutes, until a cake tester comes out clean. Cool in the pans for 30 minutes, then turn them out onto a cooling rack and cool completely.
Place 1 layer, flat side up, on a flat plate or cake pedestal. With a knife or offset spatula, spread the top with frosting. Place the second layer on top, rounded side up, and spread the frosting evenly on the top and sides of the cake.
Chocolate Frosting:
Chop the chocolate and place it in a heat-proof bowl set over a pan of simmering water. Stir until just melted and set aside until cooled to room temperature.
In the bowl of an electric mixer fitted with a paddle attachment, beat the butter on medium-high speed until light yellow and fluffy, about 3 minutes. Add the egg yolk and vanilla and continue beating for 3 minutes. Turn the mixer to low, gradually add the confectioners' sugar, then beat at medium speed, scraping down the bowl as necessary, until smooth and creamy. Dissolve the coffee powder in 2 teaspoons of the hottest tap water. On low speed, add the chocolate and coffee to the butter mixture and mix until blended. Don't whip! Spread immediately on the cooled cake.

Copyright 2006, Barefoot Contessa at Home, All Rights Reserved

My Private Notes
Add a Note
WATCH
Show: Barefoot Contessa
Episode: Flavors and Flowers
Categories:
Chocolate Cake
Cake
Chocolate
Baking
Dessert
Mixer Recipes
Recipes for a Crowd
More From: Ultimate Baking Guide
Looking for Something Else?
Healthy Highly Rated 5 Ingredients or Less Surprise Me
Chocolate Cake
Chocolate Cake
rated 4.0 of 5 stars
3
Chocolate Cake
rated 5.0 of 5 stars
1
Chocolate Cake
rated 4.5 of 5 stars
39
rated 4.6 of 5 stars
2724 Reviews

Your Rating:
Post Review
Sort by
Lisette Lopez21 days ago
rated 5 of 5 stars
So good!! Although my frosting didn’t come
Out as lightly colored as this ):
0
Comment
btate8624 days ago
rated 5 of 5 stars
THE BEST CAKE EVER!!! Yes all-caps are necessary. The cake is so delicate and moist, be careful handling it, it will stick to plastic wrap even fresh out of the freezer. I have doubled the frosting depending on what I make- standard size cakes, mini naked cakes, or cupcakes. The cake and frosting are rich and decadent without being too sweet. When she puts "good quality..." in a recipe, it does make a difference. I've used store brand, mid-grade, and high quality chocolate/cocoa and the flavor is slightly different with each- but all are still amazing!!!
**Baker beware!!! You will be tempted to lick the bowls!!! No judgement if you do because I definitely do :)
0
Comment
Lynn PryorJune 28, 2023
rated 5 of 5 stars
I can not find my earlier review where I mentioned that there was not enough icing. There is. You just need to follow the instructions and beat the batter just as directed. I just made it again for my husband's 71st birthday. And he is eating leftover icing as a Sandwich, he loves it. This is a little time-consuming for an irregular baker, but oh, so good.
To the person who was concerned about what chocolate. Don't worry, Hershey's will do just fine.
Also, the coffee brings out the chocolate flavor; don't use chickory root. You can use decaffeinated coffee.
If you found this in an old Hershey's Black Magic Cake, remember electricity was discovered in multiple places at the same time.
0
Comment
geowill.coleJune 16, 2023
rated 4 of 5 stars
Ina's original recipe recommends Valrhona cocoa, which is a Dutch-processed product. This recipe is not clear if the cocoa should be natural or Dutch-processed, which could have a significant effect on the results. The buttermilk probably provides the acidity needed to activate the baking soda, but recipes should be clear which kind of cocoa to use.
0
Comment
crysate.xJune 16, 2023
rated 5 of 5 stars
I don’t normally care for chocolate cake, but this was divine! Made it for Father’s Day, and several family members requested it for their birthday. Will definitely be making again!
0
Comment
dklecanJune 15, 2023
rated 5 of 5 stars
super delicious. However cake collapsed badly…talk about a crater. I live at 7500 ft, and i usually don’t make adaptations for chocolate cake as it is dense anyway. So in desperation, I did something crazy: grabbed a box of white cake mix, added 3 eggs, chocolate pudding, melted butter, and the leftover buttermilk. Unbelievable… it came out great, can’t tell it is boxed. I now do this cause the box version is not as sweet as Garten’s and I can focus my time on the frosting, which is the best frosting ever for taste and spreadability.

At home no one cares that the Garten cake flattens out, but for a pot luck or party, the 2 layer frosted box cake makes a grand entrance.
0
Comment
ahawk7msuJune 15, 2023
rated 5 of 5 stars
I've made this cake multiple times and it turns out beautifully every time! Delicious!
0
Comment
Petra O.June 12, 2023
rated 5 of 5 stars
This is my go-to chocolate cake. It is dense and flavorful. Other chocolate cakes are often "pale" in the chocolate department, but not this. (I think the coffee boosts the chocolate flavor.) I used Ghirardelli cocoa. Someone said that Ina uses "Pernigotti", which would be interesting to try. It is an amazing cake! I followed it to the T. I picked up an extra cup of starbucks coffee on my way home, and used that. I would just caution to not overmix as the recipe states, and also beware that the batter is very liquid. (I was thrown by that the first time I made this.) It is OK, just be sure to use a spatula to scrape anything on the bottom of the bowl one last time before putting it into the cake tin or cupcake tins. I have made it as a cake and cupcakes (same temp but for 25 mins.) a number of times and it is consistently wonderful. I do not use the frosting, I made it the first time and did not care for it. Instead I do a vanilla buttercream.
+1
Comment
crosby.loves.the.simsJune 12, 2023
Awesome, I need to try this recipe. I have heard it is amazing.
0
Comment
claremaloney11215June 10, 2023
Making cupcakes and using the recipe. Any recommendations on how to alter temp and time for the cupcakes (standard and mini size cups).
0
Comment
Petra O.June 11, 2023
I am doing the same. I found a link from Ina that gives the instructions (Pasting link) but essentially, cook at the same temp for 25 minutes.

https://www.bing.com/ck/a?!&&p=b9c4eb35451c909bJmltdHM9MTY4NjQ0MTYwMCZpZ3VpZD0xOTM0MWRlNi0xODYwLTY1MjMtMGU2ZS0wYzBiMWM2MDY3ZTYmaW5zaWQ9NTE5Mw&ptn=3&hsh=3&fclid=19341de6-1860-6523-0e6e-0c0b1c6067e6&psq=aunt+beatty+chocolate+cake+into+cupcakes&u=a1aHR0cHM6Ly93d3cuc2hla25vd3MuY29tL2Zvb2QtYW5kLXJlY2lwZXMvYXJ0aWNsZXMvMjQ4ODE1MS9pbmEtZ2FydGVuLWJlYXR0eXMtY2hvY29sYXRlLWNha2UtY3VwY2FrZS1yZWNpcGUv&ntb=1

0
Comment
Petra O.June 11, 2023
Bake at same temp for 25 minutes... I found a post from Ina on this...
0
Comment
barnardbethJune 9, 2023
rated 5 of 5 stars
I made this cake today for my father’s 80th birthday. First- DO NOT use cake pans less than 2 inches tall (what the recipe calls for), second- DO NOT open the oven door before 35 minutes. My cake panda are Wilton brand and only 1.5 inches- they over flowed and I opened the oven door to let smoke escape. All that said- the cake is rescuable- and DELICIOUS! Just follow all steps exactly.
0
Comment
Show more reviews
👩‍🍳 What's Cooking
Our Best Healthy Breakfast Ideas
Dishes That Require Very Little Cleanup
Slow Cooker Recipes You'll Love
Discover More Recipes...
What's New
The Best Amazon Prime Day 2023 Kitchen Deals
Top Grocery Sales on Prime Day
What Food Network Editors Are Buying on Prime Day

Sign up for the Food Network Shopping Newsletter
Privacy Policy

Sign Up
Related Pages
Mocha Chocolate Icebox Cake Recipe
Chocolate Ganache Cake Recipe
Decadent (Gluten-Free!) Chocolate Cake Recipe
Chocolate Cassis Cake Recipe
Chocolate Cake with Mocha Frosting Recipe
Bittersweet Chocolate Cake Recipe
Site Map Visitor Agreement AdChoices Privacy Notice About Newsroom Advertise Help TV Ratings Online Closed Captioning California Privacy Notice Accessibility Newsletters Discovery, Inc. Do Not Sell or Share My Personal Information
International Editions The Discovery Family of Networks © 2023 Warner Bros. Discovery, Inc. or its subsidiaries and affiliates. All rights reserved.

What I've noticed is that a lot of whitespace issues are occurring, as well as elements hidden due to specificity or noscript. As a temporary workaround in the most recent pull request, I made all noscript elements hidden by default. A lot of newlines are still being messed with. Part of this is the fact that I trim using String.prototype.trim on all of the strings returned by text nodes. This reduces a weird result of a ton of redundant whitespace, but may also be messing with the final result.
As for specificity, a lot of elements that are represented as dropdowns are visible in JSDOM, but hidden for the browser. This would stem from the fact that my method of getting the computed style does not take into account specificity, which may be relevant for dropdowns. This will have to be fixed, but I am not sure how.

@davletovalmir
Copy link

Hi @TKDKid1000, is this PR expected to get merged anytime soon? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

innerText implementation
2 participants