Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 5b1b5cc

Browse files
committed
Add API for additional priority settings
RequirejsHelper#_priority is an experimental API used for JS test suite integration.
1 parent de30389 commit 5b1b5cc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/helpers/requirejs_helper.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
require 'requirejs/error'
22

33
module RequirejsHelper
4+
# EXPERIMENTAL: Additional priority settings appended to
5+
# any user-specified priority setting by requirejs_include_tag.
6+
# Used for JS test suite integration.
7+
mattr_accessor :_priority
8+
@@_priority = []
9+
410
def _requirejs_data(name, &block)
511
{}.tap do |data|
612
if name
@@ -35,7 +41,12 @@ def requirejs_include_tag(name=nil, &block)
3541

3642
_once_guard do
3743
unless requirejs.run_config.empty?
38-
run_config = requirejs.run_config
44+
run_config = requirejs.run_config.dup
45+
unless _priority.empty?
46+
run_config = run_config.dup
47+
run_config[:priority] ||= []
48+
run_config[:priority].concat _priority
49+
end
3950
if Rails.application.config.assets.digest
4051
modules = requirejs.build_config['modules'].map { |m| requirejs.module_name_for m }
4152

0 commit comments

Comments
 (0)