Imagine waking up on a chilly morning, the scent of sizzling sausage filling the air, and a hot, hearty breakfast waiting for you. A comforting plate of creamy hash brown casserole with sausage and eggs is exactly what you need to start your day off right. Whether it’s for a weekend brunch, a holiday breakfast, or a quick and satisfying meal, this dish is your go-to recipe.
What makes this casserole so special? It combines all the best elements of breakfast—creamy texture, savory sausage, cheesy goodness, and crispy hash browns—into one dish. Plus, it’s super easy to make and sure to impress your family or guests.
Let’s dive into why this casserole is about to become your new favorite and how you can make it from scratch in just a few simple steps!
Why You’ll Love This Creamy Hash Brown Casserole with Sausage and Eggs
Breakfast casseroles are a game changer in the kitchen. They’re easy to make, they feed a crowd, and they offer endless opportunities for customization. This creamy hash brown casserole with sausage and eggs is the epitome of comfort food, offering a rich, creamy texture with a savory depth of flavor. Whether you’re hosting a holiday brunch or just need a filling meal for your family, this dish is the perfect option. Here’s why you’ll fall in love with it:
- Creamy Texture: The cream cheese and eggs create a velvety base, while the hash browns provide a satisfying bite.
- Savory Flavor: The combination of hot sausage, garlic, onion powder, and cheddar cheese makes every bite deliciously savory.
- Easy to Make: With just a few ingredients and a simple preparation method, you can whip up this casserole without breaking a sweat.
- Feeds a Crowd: This recipe makes a generous serving, making it perfect for family breakfasts or gatherings.
The Perfect Ingredients for a Creamy Hash Brown Casserole
To make the perfect creamy hash brown casserole with sausage and eggs, you’ll need just a few key ingredients. Here’s a breakdown of what you’ll need:
- Frozen Shredded Hash Browns (30-32 oz) – These form the base of your casserole. Frozen hash browns save you time and hassle, making them the perfect choice for a quick meal.
- Hot Breakfast Sausage (2 lbs) – Choose a flavorful sausage to add a spicy kick to the dish. If you prefer a milder flavor, you can use mild sausage or turkey sausage.
- Cream Cheese (16 oz, room temperature) – Cream cheese creates the rich, creamy texture that makes this casserole so indulgent.
- Eggs (8 large) – Eggs are essential to bind the casserole together and give it structure.
- Milk (2 cups) – Milk adds to the creamy texture and helps create the custard-like consistency.
- Shredded Cheddar Cheese (2 cups) – Cheddar cheese provides sharp, cheesy goodness that melts perfectly into the casserole.
- Salt (1 tsp) – Enhances the overall flavor of the casserole.
- Black Pepper (1/2 tsp) – Adds a subtle heat and depth of flavor.
- Garlic Powder (1/4 tsp) – A mild seasoning that brings out savory notes.
- Onion Powder (1/4 tsp) – Enhances the flavor and adds a touch of sweetness.
How to Make the Perfect Creamy Hash Brown Casserole with Sausage and Eggs
Making this casserole is easy and takes only about an hour from start to finish. Follow these simple steps to create a breakfast masterpiece:
Step 1: Preheat Your Oven
Start by preheating your oven to 375°F (190°C). While the oven heats up, lightly grease a 9×13-inch baking dish with cooking spray or butter. This ensures the casserole won’t stick to the dish while baking.
Step 2: Cook the Sausage
In a large skillet over medium heat, brown the sausage. Use a spatula to break up the sausage into crumbles as it cooks. Once the sausage is fully cooked and browned, drain any excess grease and set it aside. This step is key for getting rid of extra fat and ensuring the casserole isn’t greasy.
Step 3: Mix the Cream Cheese and Eggs
In a large mixing bowl, combine the room-temperature cream cheese and eggs. Use a hand mixer or whisk to blend them together until the mixture is smooth and creamy. Add the milk, salt, black pepper, garlic powder, and onion powder to the bowl, and whisk again until everything is fully incorporated.
Step 4: Assemble the Casserole
Layer the shredded hash browns in the greased baking dish, spreading them out evenly. Next, pour the sausage mixture on top of the hash browns. Finally, pour the cream cheese and egg mixture over the entire dish, ensuring everything is well coated.
Step 5: Add Cheese
Top the casserole with shredded cheddar cheese, making sure it’s evenly spread across the top. This will melt into a beautiful, golden crust while baking.
Step 6: Bake the Casserole
Place the casserole in the preheated oven and bake for 45-50 minutes. You’ll know it’s done when the top is golden brown, and the center is set (you can test it by inserting a knife; it should come out clean).
Step 7: Let It Rest
Once the casserole is done, remove it from the oven and let it rest for about 5 minutes. This allows the casserole to firm up a bit before serving.
Why These Ingredients Work Together
Each ingredient in this casserole plays an essential role in making it a flavorful, creamy, and hearty dish.
- Frozen Shredded Hash Browns: These provide the perfect base for your casserole. They cook up crispy on the edges and soft in the center, creating the ideal texture.
- Hot Breakfast Sausage: The sausage adds a savory and spicy flavor that perfectly complements the creamy elements of the casserole.
- Cream Cheese: The cream cheese gives the casserole its rich, velvety texture, turning a simple dish into something indulgent.
- Eggs: Eggs bind all the ingredients together, creating a cohesive dish that holds its shape when served.
- Shredded Cheddar Cheese: Cheddar adds a sharp, tangy flavor and a gooey texture that melts perfectly into the casserole.
- Seasonings: Salt, pepper, garlic powder, and onion powder work together to enhance the flavors of the casserole, adding depth and savory notes.
Expert Tips for Perfecting Your Hash Brown Casserole
- Thaw the Hash Browns: For best results, thaw the hash browns before using them. This helps ensure they cook evenly and don’t make the casserole soggy.
- Use Room Temperature Cream Cheese: Room-temperature cream cheese is much easier to mix and results in a smoother texture.
- Cook the Sausage Well: Brown the sausage thoroughly to ensure it’s cooked through and crumbles nicely into the casserole.
- Don’t Overcrowd the Dish: Make sure the ingredients are spread evenly in the dish to allow for even cooking. If the casserole is too packed, it may take longer to bake.
How to Serve and Pair Your Hash Brown Casserole
This creamy hash brown casserole with sausage and eggs is hearty enough to stand alone, but it pairs beautifully with other breakfast favorites. Consider serving it with:
- Fresh Fruit: A light fruit salad can balance the richness of the casserole.
- Beverages: Pair the casserole with freshly brewed coffee, tea, or a glass of orange juice for a complete breakfast.
- Toppings: Add a dollop of sour cream, a sprinkle of chopped green onions, or a drizzle of hot sauce for extra flavor.
Customizing Your Hash Brown Casserole: Endless Possibilities
One of the best things about this casserole is how versatile it is. You can easily customize it to suit your taste preferences. Here are some ideas:
- Add Vegetables: Mix in chopped bell peppers, onions, spinach, or mushrooms to add more depth and nutrition to the casserole.
- Use Different Cheeses: Swap cheddar for pepper jack, mozzarella, or Swiss for a different flavor profile.
- Try Other Meats: If you prefer, you can use bacon, ham, or turkey sausage instead of hot breakfast sausage.
- Spice It Up: For an extra kick, add diced jalapeños, hot sauce, or chili flakes.
How to Store and Reheat Your Casserole
This casserole makes great leftovers! Here’s how to store and reheat it:
- Refrigeration: Store leftovers in an airtight container in the refrigerator for up to 3 days.
- Reheating: Reheat individual portions in the microwave for 1-2 minutes or reheat the entire casserole in the oven at 325°F for 15-20 minutes.
- Freezing: To freeze, wrap the casserole tightly in plastic wrap and foil. It can be frozen for up to 2 months. Thaw overnight in the fridge before reheating.
Balancing Comfort and Nutrition in This Breakfast Casserole
While this casserole is undeniably indulgent, it’s also packed with protein and provides a filling, satisfying meal. Here’s a quick breakdown of the nutritional content per serving:
- Calories: 420
- Protein: 22g
- Carbohydrates: 18g
- Fat: 30g
For a lighter version, try using turkey sausage, low-fat cheese, and skim milk. You can also add vegetables to increase the fiber content.
Frequently Asked Questions About Creamy Hash Brown Casserole with Sausage and Eggs
- Can I prepare this casserole the night before?
Yes! You can assemble the casserole the night before, cover it tightly, and refrigerate. Bake it fresh in the morning for an easy breakfast. - What’s the best way to reheat leftovers?
For the best texture, reheat individual portions in the microwave. You can also reheat the entire casserole in the oven at 325°F. - Can I substitute fresh potatoes for hash browns?
Yes, you can shred and drain fresh potatoes, but frozen hash browns save time and add the perfect texture to the dish. - Can I use a different type of sausage?
Absolutely! You can use mild sausage, bacon, or turkey sausage depending on your preference. - Is this casserole gluten-free?
Yes, as long as all your ingredients are gluten-free. Check the sausage label and any other pre-packaged ingredients. - Can I make this casserole vegetarian?
Yes, simply swap the sausage for a meatless alternative or load up on veggies for a delicious vegetarian version.
Your New Favorite Breakfast Casserole Recipe
This creamy hash brown casserole with sausage and eggs is a delicious, comforting, and easy-to-make dish that’s perfect for any occasion. Whether you’re feeding a crowd, prepping for a busy week, or just want to enjoy a hearty breakfast, this casserole has you covered. Give it a try, customize it to your liking, and enjoy the warmth and comfort of this all-in-one breakfast dish.
Don’t forget to share your experience and tag your creations on social media!
Creamy Hash Brown Casserole with Sausage and Eggs: The Ultimate Comfort Food
Total Time: 1 hour 5 minutes
Yield: 8 servings
Description
A hot, hearty breakfast casserole that combines crispy hash browns, spicy sausage, creamy cheese, and eggs into a single dish. Perfect for family breakfasts, holiday mornings, or meal prep, this recipe is easy to make and incredibly satisfying.
Ingredients
- 1 bag frozen shredded hash browns (30–32 oz)
- 2 lbs hot breakfast sausage
- 16 oz cream cheese, softened to room temperature
- 8 large eggs
- 2 cups milk
- 2 cups shredded cheddar cheese
- 1 tsp salt
- ½ tsp black pepper
- ¼ tsp garlic powder
- ¼ tsp onion powder
Instructions
- Preheat Oven: Preheat your oven to 375°F (190°C) and grease a 9×13-inch baking dish with butter or non-stick spray.
- Cook Sausage: In a large skillet over medium heat, crumble and cook the sausage until browned. Drain any excess grease and set aside.
- Mix Custard Base: In a large mixing bowl, combine the cream cheese and eggs. Use a whisk or hand mixer to blend until smooth. Add milk, salt, pepper, garlic powder, and onion powder, and mix well.
- Assemble Casserole: Spread the shredded hash browns evenly in the prepared baking dish. Layer the cooked sausage over the hash browns. Pour the custard mixture evenly over the layers.
- Add Cheese: Sprinkle shredded cheddar cheese evenly on top.
- Bake: Place the casserole in the preheated oven and bake for 45–50 minutes, or until the top is golden brown and the center is set.
- Let Rest and Serve: Remove from the oven and let the casserole rest for 5 minutes before serving.
Notes
- Make Ahead: Assemble the casserole the night before, cover it tightly, and refrigerate. Bake fresh in the morning.
- Customizations: Add vegetables like bell peppers or spinach, use turkey sausage for a lighter option, or try different cheeses for unique flavors.
- Reheating: Reheat leftovers in the microwave or oven. For freezing, wrap tightly and thaw in the refrigerator overnight before reheating.
- Prep Time: 15 minutes
- Cook Time: 50 minutes
- Category: Breakfast
- Method: Baking
- Cuisine: American
window.trCommon={“minRating”:6,”ajaxurl”:”https:\/\/forurenergy.com\/wp-admin\/admin-ajax.php”,”ratingNonce”:””,”postId”:311};
window.TastyRecipes = window.TastyRecipes || {};
window.TastyRecipes.smoothScroll = {
init() {
document.addEventListener( ‘click’, ( e ) => {
let anchor = e.target;
if ( anchor.tagName !== ‘A’ ) {
anchor = anchor.closest( ‘a.tasty-recipes-scrollto’ );
}
if ( ! anchor || ! anchor.classList.contains( ‘tasty-recipes-scrollto’ ) ) {
return;
}
const elementHref = anchor.getAttribute( ‘href’ );
if ( ! elementHref ) {
return;
}
e.preventDefault();
this.goToSelector( elementHref );
});
},
goToSelector( selector ) {
const element = document.querySelector( selector );
if ( ! element ) {
return;
}
element.scrollIntoView( { behavior: ‘smooth’ } );
}
};
document.addEventListener(
‘DOMContentLoaded’,
() => window.TastyRecipes.smoothScroll.init()
);
(function(){
document.querySelectorAll(‘[data-tr-ingredient-checkbox]’).forEach(function(el) {
var input = el.querySelector(‘.tr-ingredient-checkbox-container input[type=”checkbox”]’);
if ( ! input ) {
return;
}
if (input.checked) {
el.dataset.trIngredientCheckbox = ‘checked’;
}
el.addEventListener(‘click’, function(event) {
if ( ‘A’ === event.target.nodeName
|| ‘INPUT’ === event.target.nodeName
|| ‘LABEL’ === event.target.nodeName ) {
return;
}
input.click();
});
input.addEventListener(‘change’, function() {
el.dataset.trIngredientCheckbox = input.checked ? ‘checked’ : ”;
});
});
}());
window.TastyRecipes = window.TastyRecipes || {};
window.TastyRecipes.cookMode = {
wakeLockApi: false,
wakeLock: false,
cookModeSelector: ‘.tasty-recipes-cook-mode’,
init() {
if (“wakeLock” in navigator && “request” in navigator.wakeLock) {
this.wakeLockApi = navigator.wakeLock;
}
const cookModes = document.querySelectorAll(this.cookModeSelector);
if (cookModes.length > 0) {
for (const cookMode of cookModes) {
if (this.wakeLockApi) {
cookMode.querySelector(‘input[type=”checkbox”]’).addEventListener(“change”, event => {
this.checkboxChange(event.target);
}, false);
} else {
cookMode.style.display = “none”;
}
}
}
},
checkboxChange(checkbox) {
if (checkbox.checked) {
this.lock();
} else {
this.unlock();
}
},
setCheckboxesState(state) {
const checkboxes = document.querySelectorAll(this.cookModeSelector + ‘ input[type=”checkbox”]’);
for (const checkbox of checkboxes) {
checkbox.checked = state;
}
},
async lock() {
try {
this.wakeLock = await this.wakeLockApi.request(“screen”);
this.wakeLock.addEventListener(“release”, () => {
this.wakeLock = false;
this.setCheckboxesState(false);
});
this.setCheckboxesState(true);
} catch (error) {
this.setCheckboxesState(false);
}
},
unlock() {
if (this.wakeLock) {
this.wakeLock.release();
this.wakeLock = false;
}
this.setCheckboxesState(false);
}
};
(function(callback) {
if (document.readyState !== “loading”) {
callback();
} else {
document.addEventListener(“DOMContentLoaded”, callback);
}
})(() => {
window.TastyRecipes.cookMode.init();
});
window.TastyRecipes = window.TastyRecipes || {};
window.TastyRecipes.staticTooltip = {
element: null,
tooltipElement: null,
deleting: false,
init( element ) {
if ( this.deleting ) {
return;
}
this.element = element;
this.buildElements();
},
destroy() {
if ( ! this.tooltipElement || this.deleting ) {
return;
}
this.deleting = true;
this.tooltipElement.classList.remove( ‘opened’ );
setTimeout( () => {
this.tooltipElement.remove();
this.deleting = false;
}, 500 );
},
buildElements() {
const tooltipElement = document.createElement( ‘div’ );
tooltipElement.classList.add( ‘tasty-recipes-static-tooltip’);
tooltipElement.setAttribute( ‘id’, ‘tasty-recipes-tooltip’ );
const currentTooltipElement = document.getElementById( ‘tasty-recipes-tooltip’ );
if ( currentTooltipElement ) {
document.body.replaceChild( tooltipElement, currentTooltipElement );
} else {
document.body.appendChild( tooltipElement );
}
this.tooltipElement = document.getElementById( ‘tasty-recipes-tooltip’ );
},
show() {
if ( ! this.tooltipElement ) {
return;
}
const tooltipTop = this.element.getBoundingClientRect().top
+ window.scrollY
– 10 // 10px offset.
– this.tooltipElement.getBoundingClientRect().height;
const tooltipLeft = this.element.getBoundingClientRect().left
– ( this.tooltipElement.getBoundingClientRect().width / 2 )
+ ( this.element.getBoundingClientRect().width / 2 ) – 1;
const posLeft = Math.max( 10, tooltipLeft );
this.maybeRemoveTail( posLeft !== tooltipLeft );
this.tooltipElement.setAttribute( ‘style’, ‘top:’ + tooltipTop + ‘px;left:’ + posLeft + ‘px;’ );
this.tooltipElement.classList.add( ‘opened’ );
},
maybeRemoveTail( removeTail ) {
if ( removeTail ) {
this.tooltipElement.classList.add( ‘tr-hide-tail’ );
} else {
this.tooltipElement.classList.remove( ‘tr-hide-tail’ );
}
},
changeMessage( message ) {
if ( ! this.tooltipElement ) {
return;
}
this.tooltipElement.innerHTML = message;
}
};
window.TastyRecipes.ajax = {
sendPostRequest( url, data, success, failure ) {
const xhr = new XMLHttpRequest();
xhr.open( ‘POST’, url, true );
xhr.send( this.preparePostData( data ) );
xhr.onreadystatechange = () => {
if ( 4 !== xhr.readyState ) {
return;
}
if ( xhr.status === 200 ) {
success( JSON.parse( xhr.responseText ) );
return;
}
failure( xhr );
};
xhr.onerror = () => {
failure( xhr );
};
},
preparePostData( data ) {
const formData = new FormData();
for ( const key in data ) {
formData.append( key, data[key] );
}
return formData;
},
};
window.TastyRecipes.ratings = {
defaultRating: 0,
currentRatingPercentage: 100,
savingRating: false,
init( minRating ) {
this.minRating = minRating;
this.formWatchRating();
this.closeTooltipWhenClickOutside();
this.addBodyClassBasedOnSelectedRating();
this.backwardCompFormRatingPosition();
},
formWatchRating() {
const ratings = document.querySelectorAll(‘.tasty-recipes-no-ratings-buttons [data-rating]’);
if ( ratings.length {
event.preventDefault();
this.defaultRating = event.target.closest( ‘.checked’ ).dataset.rating;
this.setCheckedStar( event.target );
this.maybeSendRating( this.defaultRating, event.target );
this.setRatingInForm( this.defaultRating );
} );
}
},
closeTooltipWhenClickOutside() {
window.addEventListener( ‘click’, e => {
// Bailout (don’t remove the tooltip) when the clicked element is a rating star, or it’s the tooltip itself.
if ( e.target.closest( ‘.tasty-recipes-rating’ ) || e.target.classList.contains( ‘tasty-recipes-static-tooltip’ ) ) {
return;
}
window.TastyRecipes.staticTooltip.destroy();
} );
},
setRatingInForm( rating ) {
const ratingInput = document.querySelector( ‘#respond .tasty-recipes-rating[value=”‘ + rating + ‘”]’ );
if ( ! ratingInput ) {
return;
}
ratingInput.click();
},
addBodyClassBasedOnSelectedRating() {
const ratingInputs = document.querySelectorAll( ‘input.tasty-recipes-rating’ );
if ( ! ratingInputs ) {
return;
}
for ( const ratingInput of ratingInputs ) {
ratingInput.addEventListener( ‘click’, currentEvent => {
const selectedRating = currentEvent.target.getAttribute( ‘value’ );
this.handleBodyClassByRating( selectedRating );
this.toggleCommentTextareaRequired( selectedRating );
} );
}
},
handleBodyClassByRating( rating ) {
if ( rating < this.minRating ) {
document.body.classList.remove( 'tasty-recipes-selected-minimum-rating' );
return;
}
document.body.classList.add( 'tasty-recipes-selected-minimum-rating' );
},
toggleCommentTextareaRequired( rating ) {
const commentTextarea = document.getElementById( 'comment' );
if ( ! commentTextarea ) {
return;
}
if ( rating {
window.TastyRecipes.staticTooltip.changeMessage( response.data.message );
window.TastyRecipes.staticTooltip.show();
this.updateAverageText( response.data, recipeCardElement );
this.maybeFillCommentForm( response.data );
// Hide the tooltip after 5 seconds.
setTimeout( () => {
this.maybeResetTooltip( recipeCardElement, response.data, rating );
}, 5000 );
},
() => {
this.resetTooltip( recipeCardElement );
}
);
},
updateAverageText( data, recipeCardElement ) {
if ( ! data.average ) {
return;
}
this.setRatingPercent( data );
if ( ! data.count ) {
return;
}
const quickLink = document.querySelector( ‘.tasty-recipes-rating-link’ );
if ( quickLink ) {
this.setTextInContainer( quickLink, data );
this.setPartialStar( quickLink );
}
const cardStars = recipeCardElement.querySelector( ‘.tasty-recipes-ratings-buttons’ );
cardStars.dataset.trDefaultRating = data.average;
this.setTextInContainer( recipeCardElement.querySelector( ‘.tasty-recipes-rating’ ), data );
},
setTextInContainer( container, data ) {
if ( ! container ) {
return;
}
if ( data.label ) {
const ratingLabelElement = container.querySelector( ‘.rating-label’ );
if ( ratingLabelElement ) {
ratingLabelElement.innerHTML = data.label;
}
return;
}
const averageElement = container.querySelector( ‘.average’ );
if ( averageElement ) {
averageElement.textContent = data.average;
}
const countElement = container.querySelector( ‘.count’ );
if ( countElement ) {
countElement.textContent = data.count;
}
},
setPartialStar( container ) {
const highestStar = container.querySelector( ‘[data-rating=”‘ + Math.ceil( this.defaultRating ) + ‘”]’ );
if ( highestStar ) {
highestStar.dataset.trClip = this.currentRatingPercentage;
}
},
setRatingPercent( data ) {
this.defaultRating = data.average.toFixed( 1 );
const parts = data.average.toFixed( 2 ).toString().split( ‘.’ );
this.currentRatingPercentage = parts[1] ? parts[1] : 100;
if ( this.currentRatingPercentage === ’00’ ) {
this.currentRatingPercentage = 100;
}
},
setCheckedStar( target ) {
const cardRatingContainer = target.closest( ‘.tasty-recipes-ratings-buttons’ );
const selectedRatingElement = cardRatingContainer.querySelector( ‘[data-tr-checked]’ );
if ( selectedRatingElement ) {
delete selectedRatingElement.dataset.trChecked;
}
const thisStar = target.closest( ‘.tasty-recipes-rating’ );
thisStar.dataset.trChecked = 1;
thisStar.querySelector( ‘[data-tr-clip]’ ).dataset.trClip = 100;
},
maybeFillCommentForm( data ) {
if ( ! data.comment || ! data.comment.content ) {
return;
}
const commentForm = document.querySelector( ‘#commentform’ );
if ( ! commentForm ) {
return;
}
const commentBox = commentForm.querySelector( ‘[name=comment]’ );
if ( ! commentBox || commentBox.value ) {
return;
}
// Add comment details for editing.
commentBox.innerHTML = data.comment.content;
if ( data.comment.name ) {
commentForm.querySelector( ‘[name=author]’ ).value = data.comment.name;
commentForm.querySelector( ‘[name=email]’ ).value = data.comment.email;
}
},
maybeResetTooltip( recipeCardElement, data, rating ) {
if ( this.savingRating === rating ) {
this.resetTooltip( recipeCardElement, data );
}
},
resetTooltip( recipeCardElement, data ) {
window.TastyRecipes.staticTooltip.destroy();
this.savingRating = false;
// Reset the default rating.
const cardRatingContainer = recipeCardElement.querySelector( ‘.tasty-recipes-ratings-buttons’ );
if ( cardRatingContainer ) {
this.defaultRating = ( data && data.average ) ? data.average.toFixed(1) : cardRatingContainer.dataset.trDefaultRating;
cardRatingContainer.dataset.trDefaultRating = this.defaultRating;
this.resetSelectedStar( cardRatingContainer, data );
}
},
resetSelectedStar( cardRatingContainer ) {
const selectedRatingElement = cardRatingContainer.querySelector( ‘[data-rating=”‘ + Math.ceil( this.defaultRating ) + ‘”]’ );
if ( selectedRatingElement ) {
selectedRatingElement.querySelector( ‘[data-tr-clip]’ ).dataset.trClip = this.currentRatingPercentage;
selectedRatingElement.parentNode.dataset.trChecked = 1;
}
const previousSelectedElement= cardRatingContainer.querySelector( ‘[data-tr-checked]’ );
if ( previousSelectedElement ) {
const currentSelectedRating = previousSelectedElement.querySelector(‘[data-rating]’);
if ( currentSelectedRating !== selectedRatingElement ) {
delete previousSelectedElement.dataset.trChecked;
}
}
},
backwardCompFormRatingPosition() {
const ratingsButtons = document.querySelector( ‘#respond .tasty-recipes-ratings-buttons, #tasty-recipes-comment-rating .tasty-recipes-ratings-buttons’ );
if ( ! ratingsButtons ) {
return;
}
const ratingsButtonsStyles = window.getComputedStyle(ratingsButtons);
if ( ! ratingsButtonsStyles.display.includes( ‘flex’ ) ) {
ratingsButtons.style.direction = ‘rtl’;
}
if ( typeof tastyRecipesRating !== ‘undefined’ ) {
// Select the rating that was previously selected in admin.
ratingsButtons.querySelector( ‘.tasty-recipes-rating[value=”‘ + tastyRecipesRating + ‘”]’ ).checked = true;
}
const ratingSpans = ratingsButtons.querySelectorAll( ‘.tasty-recipes-rating’ );
for (const ratingSpan of ratingSpans) {
ratingSpan.addEventListener( ‘click’, event => {
if ( ratingSpan === event.target ) {
return;
}
ratingSpan.previousElementSibling.click();
} );
}
}
};
(function(callback) {
if (document.readyState !== “loading”) {
callback();
} else {
window.addEventListener( ‘load’, callback );
}
})(() => {
window.TastyRecipes.ratings.init( window.trCommon ? window.trCommon.minRating : 4 );
});