Skip to main content

select_options_add

Function select_options_add 

Source
pub fn select_options_add(
    it: &mut Interp,
    this: Value,
    a: &[Value],
) -> Result<Value, Value>
Expand description

select.options.add(option, before?)(HTML5 HTMLOptionsCollection。 動的にドロップダウンを構築する select.options.add(new Option(...)) という 定番イディオムが、options が素の配列(メソッドを一切持たない)を返す だけだったため丸ごと未対応(TypeError: not a function)だった。options 取得時に配列オブジェクト自身へ _select_idx(隠しプロパティ。既存の _is_headers/_ta_kind 等と同じ内部タグ付けパターン)を仕込んでおき、 この配列を経由して元の <select> を辿れるようにする。before は仕様どおり 省略時は末尾追加、数値ならその位置の既存 option の前、<option> 要素 そのものでもよい。