Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

add accepts? method

オープン
#363 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
ruby
領域
frontend

調査の方向性

HyperComponent基底クラスから始めて、既存のfires実装とaccepts_listの処理を確認します。コンポーネントが親に指定されたイベントのハンドラがあるかどうかを判定できるようにaccepts?を追加し、その後、親にハンドラがない状態でイベントを発火しても引き続きエラーが発生しないことを確認します。

索引モデルが issue の本文から書いたものです。

説明

enhancement

Its useful for a component to know if its parent is going to accept an event from the component.

   fires :foo 
  ...
  ...  accepts? :foo # does my parent component have a foo handler?

Note that firing foo will NOT cause an error even if the parent has not handler, but it still might be useful to know (i.e. to control say a save button, but only if the parent is looking for you to do the save)

Can be added with the following patch in the HyperComponent base class:

  class << self
    def accepts_list
      @accepts_list ||= {}
    end
    def fires(name, opts = {})
      aka = opts[:alias] || "#{name}!"
      name = if name =~ /^<(.+)>$/
               name.gsub(/^<(.+)>$/, '\1')
             elsif Hyperstack::Component::Event::BUILT_IN_EVENTS.include?("on#{name.event_camelize}")
               "on#{name.event_camelize}"
             else
               "on_#{name}"
             end
      validator.event(name)
      define_method(aka) { |*args| props[name]&.call(*args) }
      accepts_list[opts[:alias] || aka.chomp('!')] = name
    end
  end
  def accepts?(aka)
    props[self.class.accepts_list[aka]]
  end
主要言語
JavaScript
スター
538
フォーク
41
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hyperstack-org/hyperstack のほかの issue

hyperstack-org/hyperstack の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。