void gumbo_vector_remove(void* node, GumboVector* vector) { int index = gumbo_vector_index_of(vector, node); if (index == -1) { return; } gumbo_vector_remove_at(index, vector); }
void gumbo_vector_remove( struct GumboInternalParser* parser, void* node, GumboVector* vector) { int index = gumbo_vector_index_of(vector, node); if (index == -1) { return; } gumbo_vector_remove_at(parser, index, vector); }
void gumbo_remove_from_parent(GumboNode* node) { if (!node->parent) { return; } assert(node->parent->type == GUMBO_NODE_ELEMENT || node->parent->type == GUMBO_NODE_TEMPLATE || node->parent->type == GUMBO_NODE_DOCUMENT); GumboVector* children = &node->parent->v.element.children; if (node->parent->type == GUMBO_NODE_DOCUMENT) { children = &node->parent->v.document.children; } int index = gumbo_vector_index_of(children, node); assert(index != -1); gumbo_vector_remove_at(index, children); node->parent = NULL; node->index_within_parent = -1; for (int i = index; i < children->length; ++i) { GumboNode* child = children->data[i]; child->index_within_parent = i; } }