Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 12 of the "prepare a script" algorithm #4176

Closed
mbrubeck opened this issue Dec 2, 2014 · 7 comments
Closed

Step 12 of the "prepare a script" algorithm #4176

mbrubeck opened this issue Dec 2, 2014 · 7 comments
Labels
A-content/script Related to the script thread C-assigned There is someone working on resolving the issue E-less-complex Straightforward. Recommended for a new contributor. I-wrong An incorrect behaviour is observed.

Comments

@mbrubeck
Copy link
Contributor

mbrubeck commented Dec 2, 2014

Implement step 12 of the prepare a script algorithm from the HTML specification, by adding code to HTMLScriptElementHelpers::prepare.

  1. If the script element has an event attribute and a for attribute, then run these substeps:
  2. Let for be the value of the for attribute.
  3. Let event be the value of the event attribute.
  4. Strip leading and trailing whitespace from event and for.
  5. If for is not an ASCII case-insensitive match for the string "window", then the user agent must abort these steps at this point. The script is not executed.
  6. If event is not an ASCII case-insensitive match for either the string "onload" or the string "onload()", then the user agent must abort these steps at this point. The script is not executed.

This is part of #4089.

@mbrubeck mbrubeck added E-less-complex Straightforward. Recommended for a new contributor. I-wrong An incorrect behaviour is observed. A-content/script Related to the script thread labels Dec 2, 2014
@th0114nd
Copy link

I'm currently looking into this

@jdm jdm added the C-assigned There is someone working on resolving the issue label Dec 11, 2014
@psdh
Copy link
Contributor

psdh commented Feb 5, 2015

Assuming that @th0114nd isn't still working on this(are you?).
I will try and fix this :)

@psdh
Copy link
Contributor

psdh commented Feb 6, 2015

@mbrubeck needed some help here:
I am new to servo and rust and am facing a tough time finding how to access say the 'for' attribute,
element.get_attribute(ns!(""), &atom("for")).root() ?
I was thinking something like http://pastebin.mozilla.org/8584728

Thanks :)

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Feb 6, 2015

element.get_attribute(ns!(""), &atom("for")).root() ?

Yes, this looks correct. After you unwrap the resulting Option, you'll need to call .r().Value() to convert it to a string, like in this example code. (If you're curious why, this page has some explanations.)

@psdh
Copy link
Contributor

psdh commented Feb 6, 2015

please check this, http://pastebin.mozilla.org/8585585
I have pasted my changes and the build error that I am getting.

@jdm
Copy link
Member

jdm commented Feb 6, 2015

Ah, that happens when the string isn't in a list in https://github.com/servo/string-cache/blob/master/macros/src/atom/data.rs. In that case, you can use Atom::from_slice("event") instead of atom!("event").

@psdh
Copy link
Contributor

psdh commented Feb 22, 2015

@mbrubeck: I think this can be closed, now that the PR has merged

@Ms2ger Ms2ger closed this as completed Feb 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/script Related to the script thread C-assigned There is someone working on resolving the issue E-less-complex Straightforward. Recommended for a new contributor. I-wrong An incorrect behaviour is observed.
Projects
None yet
Development

No branches or pull requests

5 participants