@@ -1151,9 +1151,9 @@ TEST_F(GumboParserTest, Selectedcontent) {
11511151 EXPECT_EQ (GUMBO_TAG_SELECTEDCONTENT, GetTag (selectedcontent));
11521152 ASSERT_EQ (1 , GetChildCount (selectedcontent));
11531153
1154- GumboNode* text1 = GetChild (selectedcontent, 0 );
1155- ASSERT_EQ (GUMBO_NODE_TEXT, text1 ->type );
1156- EXPECT_STREQ (" hello" , text1 ->v .text .text );
1154+ GumboNode* selectedtext = GetChild (selectedcontent, 0 );
1155+ ASSERT_EQ (GUMBO_NODE_TEXT, selectedtext ->type );
1156+ EXPECT_STREQ (" hello" , selectedtext ->v .text .text );
11571157
11581158 GumboNode* option = GetChild (select, 1 );
11591159 ASSERT_EQ (GUMBO_NODE_ELEMENT, option->type );
@@ -1165,6 +1165,96 @@ TEST_F(GumboParserTest, Selectedcontent) {
11651165 EXPECT_STREQ (" hello" , text->v .text .text );
11661166}
11671167
1168+ TEST_F (GumboParserTest, SelectedcontentTwoOptions) {
1169+ Parse (" <select><button><selectedcontent></button><option>hello<option>world" );
1170+
1171+ GumboNode* body;
1172+ GetAndAssertBody (root_, &body);
1173+ ASSERT_EQ (1 , GetChildCount (body));
1174+
1175+ GumboNode* select = GetChild (body, 0 );
1176+ ASSERT_EQ (GUMBO_NODE_ELEMENT, select->type );
1177+ EXPECT_EQ (GUMBO_TAG_SELECT, GetTag (select));
1178+ ASSERT_EQ (3 , GetChildCount (select));
1179+
1180+ GumboNode* button = GetChild (select, 0 );
1181+ ASSERT_EQ (GUMBO_NODE_ELEMENT, button->type );
1182+ EXPECT_EQ (GUMBO_TAG_BUTTON, GetTag (button));
1183+ ASSERT_EQ (1 , GetChildCount (button));
1184+
1185+ GumboNode* selectedcontent = GetChild (button, 0 );
1186+ ASSERT_EQ (GUMBO_NODE_ELEMENT, selectedcontent->type );
1187+ EXPECT_EQ (GUMBO_TAG_SELECTEDCONTENT, GetTag (selectedcontent));
1188+ ASSERT_EQ (1 , GetChildCount (selectedcontent));
1189+
1190+ GumboNode* selectedtext = GetChild (selectedcontent, 0 );
1191+ ASSERT_EQ (GUMBO_NODE_TEXT, selectedtext->type );
1192+ EXPECT_STREQ (" hello" , selectedtext->v .text .text );
1193+
1194+ GumboNode* option1 = GetChild (select, 1 );
1195+ ASSERT_EQ (GUMBO_NODE_ELEMENT, option1->type );
1196+ EXPECT_EQ (GUMBO_TAG_OPTION, GetTag (option1));
1197+ ASSERT_EQ (1 , GetChildCount (option1));
1198+
1199+ GumboNode* text1 = GetChild (option1, 0 );
1200+ ASSERT_EQ (GUMBO_NODE_TEXT, text1->type );
1201+ EXPECT_STREQ (" hello" , text1->v .text .text );
1202+
1203+ GumboNode* option2 = GetChild (select, 2 );
1204+ ASSERT_EQ (GUMBO_NODE_ELEMENT, option2->type );
1205+ EXPECT_EQ (GUMBO_TAG_OPTION, GetTag (option2));
1206+ ASSERT_EQ (1 , GetChildCount (option2));
1207+
1208+ GumboNode* text2 = GetChild (option2, 0 );
1209+ ASSERT_EQ (GUMBO_NODE_TEXT, text2->type );
1210+ EXPECT_STREQ (" world" , text2->v .text .text );
1211+ }
1212+
1213+ TEST_F (GumboParserTest, SelectedcontentSelectedOption) {
1214+ Parse (" <select><button><selectedcontent></button><option>hello<option selected>world" );
1215+
1216+ GumboNode* body;
1217+ GetAndAssertBody (root_, &body);
1218+ ASSERT_EQ (1 , GetChildCount (body));
1219+
1220+ GumboNode* select = GetChild (body, 0 );
1221+ ASSERT_EQ (GUMBO_NODE_ELEMENT, select->type );
1222+ EXPECT_EQ (GUMBO_TAG_SELECT, GetTag (select));
1223+ ASSERT_EQ (3 , GetChildCount (select));
1224+
1225+ GumboNode* button = GetChild (select, 0 );
1226+ ASSERT_EQ (GUMBO_NODE_ELEMENT, button->type );
1227+ EXPECT_EQ (GUMBO_TAG_BUTTON, GetTag (button));
1228+ ASSERT_EQ (1 , GetChildCount (button));
1229+
1230+ GumboNode* selectedcontent = GetChild (button, 0 );
1231+ ASSERT_EQ (GUMBO_NODE_ELEMENT, selectedcontent->type );
1232+ EXPECT_EQ (GUMBO_TAG_SELECTEDCONTENT, GetTag (selectedcontent));
1233+ ASSERT_EQ (1 , GetChildCount (selectedcontent));
1234+
1235+ GumboNode* selectedtext = GetChild (selectedcontent, 0 );
1236+ ASSERT_EQ (GUMBO_NODE_TEXT, selectedtext->type );
1237+ EXPECT_STREQ (" world" , selectedtext->v .text .text );
1238+
1239+ GumboNode* option1 = GetChild (select, 1 );
1240+ ASSERT_EQ (GUMBO_NODE_ELEMENT, option1->type );
1241+ EXPECT_EQ (GUMBO_TAG_OPTION, GetTag (option1));
1242+ ASSERT_EQ (1 , GetChildCount (option1));
1243+
1244+ GumboNode* text1 = GetChild (option1, 0 );
1245+ ASSERT_EQ (GUMBO_NODE_TEXT, text1->type );
1246+ EXPECT_STREQ (" hello" , text1->v .text .text );
1247+
1248+ GumboNode* option2 = GetChild (select, 2 );
1249+ ASSERT_EQ (GUMBO_NODE_ELEMENT, option2->type );
1250+ EXPECT_EQ (GUMBO_TAG_OPTION, GetTag (option2));
1251+ ASSERT_EQ (1 , GetChildCount (option2));
1252+
1253+ GumboNode* text2 = GetChild (option2, 0 );
1254+ ASSERT_EQ (GUMBO_NODE_TEXT, text2->type );
1255+ EXPECT_STREQ (" world" , text2->v .text .text );
1256+ }
1257+
11681258TEST_F (GumboParserTest, ImplicitColgroup) {
11691259 Parse (" <table><col /><col /></table>" );
11701260
0 commit comments