discourse/app/assets/javascripts
David Taylor c1f74cd92a
DEV: Update default tagName and connectorTagName for plugin outlets (#13685)
This commit should be a no-op for all existing core outlets. Outlets which are introduced by themes/plugins may see a change in behavior, and should follow the steps below if they want to maintain their previous behavior.

`tagName="" connectorTagName=""` is almost always the correct choice for plugin outlets. 40eba8cd introduced a `noTags=true` shortcut which achieved this, and left a comment saying it should be the future default. This commit does exactly that. To avoid any breaking changes for plugins, all existing plugin outlets have been reviewed and adjusted by following this logic:

1) If `noTags=true`, remove the `noTags` parameter, and do not complete any further steps
2) If `tagName` is not specified, set `tagName="span"` (the previous default)
3) If `connectorTagName` is not specified, set `selectorTagName="div"` (the previous default)
4) If `tagName=""`, remove it
5) If `connectorTagName=""`, remove it

The updates were accomplished with the help of a ruby script:

```ruby
def removeAttr(tag, attribute)
  tag = tag.sub /\s#{attribute}="?\w*"? /, " "
  tag = tag.sub /\s#{attribute}="?\w*"?}}/, "}}"
  tag = tag.sub /^\s*#{attribute}="?\w*"?\n/, ""
  tag
end

files = Dir.glob("app/assets/javascripts/**/*.hbs")

puts "Checking #{files.count} files..."
files.each do |f|
  content = File.read(f)

  count = 0
  edits = 0
  content.gsub!(/{{\s*plugin-outlet.*?}}/m) do |match|
    count += 1

    result = match

    noTags = result.include?("noTags=true")
    tagName = result[/tagName="(\w*)"/, 1]
    connectorTagName = result[/connectorTagName="(\w*)"/, 1]

    if noTags
      result = removeAttr(result, "noTags")
    else
      if connectorTagName == ""
        result = removeAttr(result, "connectorTagName")
      elsif connectorTagName.nil?
        result = result.sub(/name="[\w-]+"/) { |m| "#{m} connectorTagName=\"div\"" }
      end

      if tagName == ""
        result = removeAttr(result, "tagName")
      elsif tagName.nil?
        result = result.sub(/name="[\w-]+"/) { |m| "#{m} tagName=\"span\"" }
      end
    end

    edits += 1 if match != result

    result
  end

  puts "#{count} outlets, #{edits} edited -> #{f}"

  File.write(f, content)
end
```
2022-01-06 20:38:17 +00:00
..
admin DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
confirm-new-email
discourse DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
discourse-common DEV: Re-use main app registry for raw HBS view lookups (#15456) 2022-01-05 22:22:13 +00:00
discourse-hbr DEV: Re-allow node 17, with a warning (#15083) 2021-11-24 21:16:33 +01:00
discourse-widget-hbs DEV: Re-allow node 17, with a warning (#15083) 2021-11-24 21:16:33 +01:00
docs
ember-addons
locales DEV: Use method definition syntax consistently (#14915) 2021-11-13 14:01:55 +01:00
pretty-text DEV: Remove redundant lines of code. 2022-01-06 09:02:52 +08:00
select-kit FIX: uses new format for search tag endpoint to prevent issues (#15328) 2021-12-16 11:57:47 +01:00
truth-helpers DEV: Re-allow node 17, with a warning (#15083) 2021-11-24 21:16:33 +01:00
wizard DEV: Refactor animation for invalid inputs in wizard (#15334) 2021-12-16 17:17:36 -05:00
.npmrc DEV: Prevent npm usage (#13945) 2021-08-04 22:04:58 +02:00
activate-account.js
admin.js.erb
app-boot.js
application.js DEV: Make screen-track a regular service (#14983) 2021-11-17 20:56:06 +01:00
auto-redirect.js
browser-detect.js FIX: Feature detect globalThis (#14410) 2021-09-22 11:39:41 -03:00
browser-update.js
discourse-loader.js Revert "A11Y: Improve create account modal for screen readers (#14204)" (#14233) 2021-09-03 09:42:56 +10:00
discourse-shims.js FEATURE: Local chunked uppy backup uploads with a new uploader plugin (#14894) 2021-11-23 08:45:42 +10:00
embed-application.js
ember_include.js.erb
ember_jquery.js
env.js
google-tag-manager.js
google-universal-analytics-v3.js
google-universal-analytics-v4.js
handlebars-shim.js
main_include_admin.js DEV: Remove old backup uploader and resumable.js (#15365) 2021-12-21 15:02:10 +10:00
markdown-it-bundle.js
onpopstate-handler.js
package.json
polyfills.js DEV: Remove iOS 9.3 polyfills (#15343) 2021-12-17 02:47:13 +01:00
pretty-text-bundle.js
print-page.js
service-worker.js.erb
set-prototype-polyfill.js
start-discourse.js DEV: Avoid using globals (#14909) 2021-11-13 13:10:13 +01:00
template_include.js
test-shims.js
vendor.js DEV: Drop jQuery file uploader and old upload components (#15376) 2021-12-22 08:59:44 +10:00
widget-runtime.js
wizard-application.js
wizard-shims.js DEV: Use Uppy in wizard-field-image uploads (#15269) 2021-12-13 15:23:44 +10:00
wizard-start.js
wizard-vendor.js DEV: Drop jQuery file uploader and old upload components (#15376) 2021-12-22 08:59:44 +10:00
yarn.lock SECURITY: Remove ember-cli specific response from application routes (#15155) 2021-12-01 16:10:40 +00:00