Repository: servo/servo
File: components/script/dom/html/htmlscriptelement.rs (Rust)

Code before:
                .unwrap_or(if script.external {
                    IntroductionType::SRC_SCRIPT
                } else {
                    IntroductionType::INLINE_SCRIPT
                });

        match script.type_ {
            ScriptType::Classic => {
                if self.upcast::<Node>().is_in_a_shadow_tree() {
                    document.set_current_script(None)
                } else {
                    document.set_current_script(Some(self))
                }
                let line_number = if script.external {
                    1
                } else {
                    self.line_number as u32
                };
                let window = self.owner_window();
                let global = window.as_global_scope();

                let script = global.create_a_classic_script(
                    (*script.text().str()).into(),
                    script.url,
                    script.fetch_options,
                    Some(introduction_type),
                    line_number,
                    script.external,
                );
                _ = global.run_a_classic_script(script, can_gc);
                document.set_current_script(old_script.as_deref());
            },
            ScriptType::Module => {
                document.set_current_script(None);
                self.run_a_module_script(&script, false, can_gc);
            },
            ScriptType::ImportMap => {
                // Step 6.1 Register an import map given el's relevant global object and el's result.
                register_import_map(&self.owner_global(), script.import_map, can_gc);
            },
        }

        // Step 7.
        // Decrement the ignore-destructive-writes counter of document, if it was incremented in the earlier step.
        if let Some(doc) = neutralized_doc {
            doc.decr_ignore_destructive_writes_counter();
        }

        // Step 8. If el's from an external file is true, then fire an event named load at el.
        if script.external {
            self.dispatch_load_event(can_gc);

Review comment (suggestion):
```suggestion
                // Step 6."classic".3. Run the classic script given by el's result.
                let script = global.create_a_classic_script(
```

Code after:
                } else {
                    IntroductionType::INLINE_SCRIPT
                });

        match script.type_ {
            ScriptType::Classic => {
                // Step 6."classic".1. Let oldCurrentScript be the value to which document's currentScript object was most recently set.
                let old_script = document.GetCurrentScript();

                // Step 6."classic".2. If el's root is not a shadow root,
                // then set document's currentScript attribute to el. Otherwise, set it to null.
                if self.upcast::<Node>().is_in_a_shadow_tree() {
                    document.set_current_script(None)
                } else {
                    document.set_current_script(Some(self))
                }

                let line_number = if script.external {
                    1
                } else {
                    self.line_number as u32
                };
                let window = self.owner_window();
                let global = window.as_global_scope();

                let script = global.create_a_classic_script(
                    (*script.text().str()).into(),
                    script.url,
                    script.fetch_options,
                    Some(introduction_type),
                    line_number,
                    script.external,
                );
                // Step 6."classic".3. Run the classic script given by el's result.
                _ = global.run_a_classic_script(script, can_gc);

                // Step 6."classic".4. Set document's currentScript attribute to oldCurrentScript.
                document.set_current_script(old_script.as_deref());
            },
            ScriptType::Module => {
                document.set_current_script(None);
                self.run_a_module_script(&script, false, can_gc);
            },
            ScriptType::ImportMap => {
                // Step 6.1 Register an import map given el's relevant global object and el's result.
                register_import_map(&self.owner_global(), script.import_map, can_gc);
            },
        }

        // Step 7.
        // Decrement the ignore-destructive-writes counter of document, if it was incremented in the earlier step.